# Preview an alert

Replay an alert over past data to see the incidents it would have opened. Pass `alert_id` to replay an existing alert, and send any setting you want to try instead of its own. To try an alert that doesn't exist yet, pass `dashboard_id` with `chart_id`, or `exploration_id`, with its settings. Nothing is saved. Use a replay to pick a threshold or a significance before creating an alert, or to check whether an alert is too noisy.

[endpoint]
method = "POST"
base_url = "https://telemetry.betterstack.com"
path = "/api/v3/alerts/preview"

[[body_param]]
name = "alert_id"
type = "string"
description = "ID of the alert to replay. Settings you send override it for this replay only. Get the IDs via [List chart alerts](/docs/logs/api/alerts/list/)."

[[body_param]]
name = "dashboard_id"
type = "string"
description = "Dashboard of the chart to replay a new alert on, with `chart_id`. Get the IDs via [List dashboards](/docs/logs/api/dashboards/list/)."

[[body_param]]
name = "chart_id"
type = "string"
description = "Chart to replay a new alert on, with `dashboard_id`. Get the IDs via [List charts](/docs/logs/api/charts/list/)."

[[body_param]]
name = "exploration_id"
type = "string"
description = "Exploration to replay a new alert on. Get the IDs via [List explorations](/docs/logs/api/explorations/list/)."

[[body_param]]
name = "start_time"
type = "string"
description = "Start of the window to replay, as `now-3h`, `now-7d`, an ISO 8601 time or a Unix timestamp. An ISO 8601 time without a zone is read in your time zone when you sign in with OAuth, or in UTC with an API token. Defaults to 24 hours before `end_time`. At most 7 days are replayed."

[[body_param]]
name = "end_time"
type = "string"
description = "End of the window to replay, in the same forms as `start_time`. Defaults to `now`."

[[body_param]]
name = "alert_type"
type = "string"
description = "Alert type, as on create. Required for a new alert.<br/>Valid values:<br/>`threshold`: Fires when the value crosses a threshold.<br/>`relative`: Compares the value with the previous period as a percentage change.<br/>`anomaly_rrcf`: Uses machine learning anomaly detection. Table charts don't accept it."

[[body_param]]
name = "operator"
type = "string"
description = "How the value is compared, as on create. Required for a new `threshold` or `relative` alert.<br/>Valid values:<br/>`equal`: A `threshold` alert fires when the value equals `value` or `string_value`.<br/>`not_equal`: A `threshold` alert fires when the value differs from `value` or `string_value`.<br/>`higher_than`: A `threshold` alert fires when the value is above `value`.<br/>`higher_than_or_equal`: A `threshold` alert fires when the value is at or above `value`.<br/>`lower_than`: A `threshold` alert fires when the value is below `value`.<br/>`lower_than_or_equal`: A `threshold` alert fires when the value is at or below `value`.<br/>`increases_by`: A `relative` alert fires when the value rises by `value` percent or more.<br/>`decreases_by`: A `relative` alert fires when the value falls by `value` percent or more.<br/>`changes_by`: A `relative` alert fires when the value rises or falls by `value` percent or more."

[[body_param]]
name = "value"
type = "number"
description = "Threshold value, or the percentage for a `relative` alert."

[[body_param]]
name = "string_value"
type = "string"
description = "Value to compare a string series with."

[[body_param]]
name = "anomaly_sensitivity"
type = "number"
description = "Significance of an `anomaly_rrcf` alert, 1 to 10. A higher value needs a larger deviation, so it fires less often."

[[body_param]]
name = "anomaly_trigger"
type = "string"
description = "Which anomalies an `anomaly_rrcf` alert fires on.<br/>Valid values:<br/>`any`: Fires on values above or below the prediction.<br/>`higher`: Fires on values above the prediction.<br/>`lower`: Fires on values below the prediction."

[[body_param]]
name = "confirmation_period"
type = "integer"
description = "Seconds the condition must hold before an incident opens."

[[body_param]]
name = "recovery_period"
type = "integer"
description = "Seconds the condition must be clear before an incident closes."

[[body_param]]
name = "query_period"
type = "integer"
description = "Seconds a `relative` alert compares against."

[[body_param]]
name = "check_period"
type = "integer"
description = "Seconds between checks."

[[body_param]]
name = "aggregation_interval"
type = "integer"
description = "Seconds per data point the alert evaluates."

[[body_param]]
name = "on_missing_data"
type = "string"
description = "What a check does when the query returns no data. Anomaly alerts don't accept it.<br/>Valid values:<br/>`treat_as_zero`: Checks the missing data as if the value were 0.<br/>`dont_fire`: Starts no incident for missing data.<br/>`treat_as_previous`: Checks the missing data as if it had the previous value.<br/>`start_incident`: Starts an incident when the query returns no data."

[[body_param]]
name = "series_names"
type = "array of strings"
description = "Replay only these series. Can't be combined with `series_names_except`."

[[body_param]]
name = "series_names_except"
type = "array of strings"
description = "Replay every series except these."

[[body_param]]
name = "additional_conditions"
type = "array of objects"
description = "Extra conditions combined with the alert's own, as on create. The replay fires only where a series meets every condition that covers it. For an existing alert, the conditions you send replace its own for the replay. Send `[]` to replay it without them."

[[body_param]]
name = "additional_conditions[].alert_type"
type = "string"
description = "The type of the condition, `threshold` or `relative`."

[[body_param]]
name = "additional_conditions[].operator"
type = "string"
description = "The comparison the condition makes, from the same values as `operator`."

[[body_param]]
name = "additional_conditions[].value"
type = "number"
description = "Threshold value."

[[body_param]]
name = "additional_conditions[].string_value"
type = "string"
description = "Threshold value for a string series."

[[body_param]]
name = "additional_conditions[].series_names"
type = "array of strings"
description = "The series the condition is limited to. An empty list means every series."

[[body_param]]
name = "additional_conditions[].series_names_except"
type = "array of strings"
description = "The series the condition ignores while it watches every other series."

[[query_param]]
name = "team_id"
type = "string"
description = "Team to use, such as `t123`. Get the ID via [List teams](/docs/uptime/api/teams/list/). Required when you can access more than one team."

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = false
type = "string"
[/endpoint]

[responses]
[[response]]
status = 200
description = "Returns the replay's report as a plain JSON object."
body = '''
{
  "data": {
    "chart": {
      "id": "456",
      "name": "Errors",
      "chart_type": "line_chart"
    },
    "configuration": {
      "alert_type": "threshold",
      "operator": "higher_than",
      "value": 5000,
      "confirmation_period": 60,
      "recovery_period": 300
    },
    "window": {
      "from": "2026-11-15T10:00:00Z",
      "to": "2026-11-22T10:00:00Z",
      "requested_from": "2026-11-15T10:00:00Z",
      "requested_to": "2026-11-22T10:00:00Z",
      "seconds": 604800,
      "interval_seconds": 60
    },
    "totals": {
      "incidents": 3,
      "incidents_per_day": 0.43,
      "alerting_seconds": 1260,
      "alerting_share": 0.2,
      "alerting_points": 21
    },
    "incidents": [
      {
        "started_at": "2026-11-20T08:12:00Z",
        "ended_at": "2026-11-20T08:31:00Z",
        "duration_seconds": 1140,
        "series_names": [
          "api"
        ],
        "open": false
      }
    ],
    "series": [
      {
        "name": "api",
        "alerting_points": 21
      }
    ],
    "unchecked_series": [],
    "omitted_series": [],
    "warnings": [
      {
        "code": "range_clamped",
        "message": "A replay covers at most 7 days, so the window was cut back to start at 2026-11-15 10:00 UTC."
      }
    ]
  }
}
'''

[[response]]
status = 401
description = "The API token is missing or invalid."
body = '''
{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}
'''

[[response]]
status = 403
description = "The token is read-only, or its scopes don't permit the action."
body = '''
{
  "errors": "This API token is read-only and cannot be used for write operations."
}
'''

[[response]]
status = 404
description = "The alert, dashboard, chart or exploration wasn't found."

[[response]]
status = 422
description = "The request doesn't send exactly one of `alert_id`, `dashboard_id` with `chart_id`, or `exploration_id`, sends a setting the replay doesn't accept or a time in a format it doesn't recognize, or names a chart that can't be replayed, such as a tail or table chart."
body = '''
{
  "errors": "Tail charts and table charts can't be previewed."
}
'''
[/responses]

[params]
title = "Response attributes"

[[param]]
name = "chart"
type = "object"
description = "The chart replayed, with its `id`, `name` and `chart_type`."

[[param]]
name = "configuration"
type = "object"
description = "The settings the replay used. For an existing alert, those are its own settings with the ones you sent on top."

[[param]]
name = "window"
type = "object"
description = "The window replayed, with its `from`, `to`, length in `seconds` and `interval_seconds` per data point. `requested_from` and `requested_to` are the window asked for."

[[param]]
name = "totals"
type = "object"
description = "Totals for the replay. `incidents` is how many incidents the alert would have opened, and `incidents_per_day` how many a day. `alerting_seconds` is how long the alert would have been alerting, and `alerting_share` that time as a fraction of the window. `alerting_points` counts the data points that alerted."

[[param]]
name = "incidents"
type = "array of objects"
description = "The incidents the alert would have opened, oldest first."

[[param]]
name = "incidents[].started_at"
type = "datetime"
description = "When the incident would have started, once the condition held for `confirmation_period`. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "incidents[].ended_at"
type = "datetime or null"
description = "When the incident would have ended. For an incident still open, it's the end of the window. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "incidents[].duration_seconds"
type = "integer"
description = "How long the incident would have lasted, in seconds."

[[param]]
name = "incidents[].series_names"
type = "array of strings"
description = "The series that caused the incident."

[[param]]
name = "incidents[].open"
type = "boolean"
description = "Whether the incident was still open at the end of the window."

[[param]]
name = "series"
type = "array of objects"
description = "Every series the replay checked."

[[param]]
name = "series[].name"
type = "string"
description = "The series name."

[[param]]
name = "series[].alerting_points"
type = "integer"
description = "How many of the series' data points breached the condition."

[[param]]
name = "unchecked_series"
type = "array of strings"
description = "Series the anomaly detection couldn't check."

[[param]]
name = "omitted_series"
type = "array of strings"
description = "Series the replay skipped. A replay checks at most 50 series, or 10 for an anomaly alert."

[[param]]
name = "warnings"
type = "array of objects"
description = "Reasons the numbers may be incomplete, such as a shortened window or skipped series."

[[param]]
name = "warnings[].code"
type = "string"
description = "A code to check for, such as `range_clamped`, `range_shortened`, `series_omitted` or `series_error`."

[[param]]
name = "warnings[].message"
type = "string"
description = "What the warning means for the numbers, in a sentence."
[/params]

#### Example cURL

[code-tabs]
```shell
[label Replay an alert]
curl --request POST \
  --url https://telemetry.betterstack.com/api/v3/alerts/preview \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "alert_id": "1234",
  "start_time": "now-7d"
}'
```
```shell
[label Try a threshold on a chart]
curl --request POST \
  --url https://telemetry.betterstack.com/api/v3/alerts/preview \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "dashboard_id": "1234",
  "chart_id": "18718",
  "alert_type": "threshold",
  "operator": "higher_than",
  "value": 5000,
  "start_time": "now-7d"
}'
```
[/code-tabs]
