BrowserStack AI Evals

Alerts

Create, list, update, pause, resume, and delete alert rules from the SDK across TypeScript, Python, Java, and Go.

Alerts

Alert rules keep an eye on a metric — latency, cost, tokens, error count, or an evaluation score — over your traces or sessions and send you a notification when the metric crosses a threshold.

Setup

Put your public and secret keys in your environment, then create one client and reuse it for every call on this page.

import { AISDK } from '@browserstack/ai-sdk';const publicKey = process.env.AISDK_PUBLIC_KEY!;const secretKey = process.env.AISDK_SECRET_KEY!;const client = new AISDK({  publicKey,  secretKey,});

Create an alert

const alert = await client.alert.create({  name,  description: 'all-fields alert',  scope: 'TRACE',  aggregation: 'AVG',  metric: 'latency',  operator: 'GT',  threshold: 750,  unit: 'ms',  windowMinutes: 5,  cooldownMinutes: 10,  environments: ['default'],  notifications: [    { channel: 'webhook', enabled: true, config: { url: 'https://example.com/sdk-test-webhook' } },  ],});

The response includes everything the server saved — defaults it filled in for you, and the alert's id, which you'll use for every follow-up call.

Creates a new alert in your project. The server validates the window size, metric, environments, filter columns, and each notification target before saving.

ParamTypeRequiredDescription
namestringtrueA name for the alert. 1–255 characters.
descriptionstring | nullfalseOptional free-form description. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricstringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdnumberfalseThe value the metric is compared against.
unitstring | nullfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
trueHow far back to look when aggregating the metric.
cooldownMinutesnumberfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsstring[]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsNotificationTarget[]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
namestrtrueA name for the alert. 1–255 characters.
descriptionOptional[str]falseOptional free-form description. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricOptional[object]falseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdOptional[float]falseThe value the metric is compared against.
unitOptional[str]falseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
window_minutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldown_minutesOptional[int]falseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsOptional[list[str]]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationslist[NotificationTargetInput]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
nameStringtrueA name for the alert. 1–255 characters.
descriptionStringfalseOptional free-form description. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricStringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdDoublefalseThe value the metric is compared against.
unitStringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldownMinutesIntegerfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsList<String>falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsList<NotificationTarget>trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
NamestringtrueA name for the alert. 1–255 characters.
Description*stringfalseOptional free-form description. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
Metric*stringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
Threshold*float64falseThe value the metric is compared against.
Unit*stringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
WindowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
trueHow far back to look when aggregating the metric.
CooldownMinutes*intfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
Environments*[]stringfalseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
Notifications[]NotificationTargettrueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

List alerts

const res = await client.alert.list();

meta contains the pagination fields (page, limit, totalItems, totalPages). Asking for a page past the last one returns an empty data array — not an error.

Lists the alerts in your project, paginated. You can narrow the results by searching the name, or by filtering on status, scope, or metric.

ParamTypeRequiredDescription
pagenumberfalse1-indexed page number (default 1)
Default: 1
limitnumberfalsePage size, max 100 (default 50)
Default: 50
searchstringfalseSubstring match on alert name (case-insensitive)
status'active' | 'paused'
"active" | "paused"
falseFilter by status — "active" or "paused"
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricstringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageOptional[int]false1-indexed page number (default 1)
Default: 1
limitOptional[int]falsePage size, max 100 (default 50)
Default: 50
searchOptional[str]falseSubstring match on alert name (case-insensitive)
statusOptional[str]
"active", "paused"
falseFilter by status — "active" or "paused"
scopeOptional[str]
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricOptional[str]falseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageIntegerfalse1-indexed page number (default 1)
Default: 1
limitIntegerfalsePage size, max 100 (default 50)
Default: 50
searchStringfalseSubstring match on alert name (case-insensitive)
statusString
"active", "paused"
falseFilter by status — "active" or "paused"
scopeString
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricStringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
Page*intfalse1-indexed page number (default 1)
Default: 1
Limit*intfalsePage size, max 100 (default 50)
Default: 50
Search*stringfalseSubstring match on alert name (case-insensitive)
Status*string
"active", "paused"
falseFilter by status — "active" or "paused"
Scope*string
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
Metric*stringfalseExact match on the metric key (e.g. "latency", "score:relevance")

Get an alert by id

const fetched = await client.alert.get(alertId);

Get one alert by id

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Update an alert

Only the fields you send are updated — everything else stays the way it was. Handy for tweaking a threshold without rewriting the whole request.

const updated = await client.alert.update(alertId, {  threshold: 999,  description: 'updated description',});

Updates the alert. Only the fields you send are changed — anything you leave out stays the same. Pass `description: null` to clear the description.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
namestringfalseNew name. 1–255 characters.
descriptionstring | nullfalseNew description. Pass `null` to clear it. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseNew aggregation over the window.
metricstringfalseNew metric — a built-in metric or `score:<name>`.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseNew comparison between the aggregated metric and the threshold.
thresholdnumberfalseNew threshold.
unitstring | nullfalseNew display unit. Pass `null` to clear.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
falseNew look-back window in minutes.
cooldownMinutesnumberfalseNew cooldown between fires.
environmentsstring[]falseNew environments. Empty means evaluate every environment.
notificationsNotificationTarget[]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
nameOptional[str]falseNew name. 1–255 characters.
descriptionOptional[str]falseNew description. Pass `null` to clear it. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricOptional[object]falseNew metric — a built-in metric or `score:<name>`.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdOptional[float]falseNew threshold.
unitOptional[str]falseNew display unit. Pass `null` to clear.
window_minutesOptional[AlertConfigWindowMinutes]
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldown_minutesOptional[int]falseNew cooldown between fires.
environmentsOptional[list[str]]falseNew environments. Empty means evaluate every environment.
notificationsOptional[list[NotificationTargetInput]]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
nameStringfalseNew name. 1–255 characters.
descriptionStringfalseNew description. Pass `null` to clear it. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricStringfalseNew metric — a built-in metric or `score:<name>`.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdDoublefalseNew threshold.
unitStringfalseNew display unit. Pass `null` to clear.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldownMinutesIntegerfalseNew cooldown between fires.
environmentsList<String>falseNew environments. Empty means evaluate every environment.
notificationsList<NotificationTarget>falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
Name*stringfalseNew name. 1–255 characters.
Description*stringfalseNew description. Pass `null` to clear it. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseNew aggregation over the window.
Metric*stringfalseNew metric — a built-in metric or `score:<name>`.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseNew comparison between the aggregated metric and the threshold.
Threshold*float64falseNew threshold.
Unit*stringfalseNew display unit. Pass `null` to clear.
WindowMinutes*AlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
falseNew look-back window in minutes.
CooldownMinutes*intfalseNew cooldown between fires.
Environments*[]stringfalseNew environments. Empty means evaluate every environment.
Notifications*[]NotificationTargetfalseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

Pause and resume

pause() disables an alert without deleting it — useful during a maintenance window when you don't want false alarms. resume() turns it back on. Both are simple wrappers around the /toggle endpoint.

const paused = await client.alert.pause(alertId);
const resumed = await client.alert.resume(alertId);

Pause an alert without deleting its config. Convenience wrapper for `toggleAlert(alertId, false)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Re-enable a previously-paused alert. Convenience wrapper for `toggleAlert(alertId, true)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Delete an alert

const result = await client.alert.delete(alert.id);

Calling get() on the same id afterwards returns 404.

Delete an alert

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Complete example

Every step above, stitched together into one block you can copy and adapt. Fill in alertId where a later step needs the id returned by create.

// 1. Set up the clientimport { AISDK } from '@browserstack/ai-sdk';const publicKey = process.env.AISDK_PUBLIC_KEY!;const secretKey = process.env.AISDK_SECRET_KEY!;const client = new AISDK({  publicKey,  secretKey,});// 2. Per-run variablesconst name = 'High p95 latency on production traces';// 3. Create an alertconst alert = await client.alert.create({  name,  description: 'all-fields alert',  scope: 'TRACE',  aggregation: 'AVG',  metric: 'latency',  operator: 'GT',  threshold: 750,  unit: 'ms',  windowMinutes: 5,  cooldownMinutes: 10,  environments: ['default'],  notifications: [    { channel: 'webhook', enabled: true, config: { url: 'https://example.com/sdk-test-webhook' } },  ],});// 4. Grab the id for later stepsconst alertId = alert.id;// 5. List alertsconst res = await client.alert.list();// 6. Fetch it by idconst fetched = await client.alert.get(alertId);// 7. Update the thresholdconst updated = await client.alert.update(alertId, {  threshold: 999,  description: 'updated description',});// 8. Pause during maintenanceconst paused = await client.alert.pause(alertId);// 9. Resume when doneconst resumed = await client.alert.resume(alertId);// 10. Delete the alertconst result = await client.alert.delete(alert.id);

Setup

Put your public and secret keys in your environment, then create one client and reuse it for every call on this page.

from browserstack_ai_sdk import AISDKclient = AISDK(    public_key=os.environ["AISDK_PUBLIC_KEY"],    secret_key=os.environ["AISDK_SECRET_KEY"],)

Create an alert

alert = client.alert.create(    name=name,    scope="TRACE",    aggregation="AVG",    metric="latency",    operator="GT",    threshold=750,    window_minutes=5,    cooldown_minutes=10,    environments=["default"],    notifications=[        {            "channel": "webhook",            "enabled": True,            "config": {"url": "https://example.com/alerts/webhook"},        },    ],    description="all-fields alert",    unit="ms",)

The response includes everything the server saved — defaults it filled in for you, and the alert's id, which you'll use for every follow-up call.

Creates a new alert in your project. The server validates the window size, metric, environments, filter columns, and each notification target before saving.

ParamTypeRequiredDescription
namestringtrueA name for the alert. 1–255 characters.
descriptionstring | nullfalseOptional free-form description. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricstringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdnumberfalseThe value the metric is compared against.
unitstring | nullfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
trueHow far back to look when aggregating the metric.
cooldownMinutesnumberfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsstring[]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsNotificationTarget[]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
namestrtrueA name for the alert. 1–255 characters.
descriptionOptional[str]falseOptional free-form description. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricOptional[object]falseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdOptional[float]falseThe value the metric is compared against.
unitOptional[str]falseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
window_minutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldown_minutesOptional[int]falseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsOptional[list[str]]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationslist[NotificationTargetInput]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
nameStringtrueA name for the alert. 1–255 characters.
descriptionStringfalseOptional free-form description. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricStringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdDoublefalseThe value the metric is compared against.
unitStringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldownMinutesIntegerfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsList<String>falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsList<NotificationTarget>trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
NamestringtrueA name for the alert. 1–255 characters.
Description*stringfalseOptional free-form description. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
Metric*stringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
Threshold*float64falseThe value the metric is compared against.
Unit*stringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
WindowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
trueHow far back to look when aggregating the metric.
CooldownMinutes*intfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
Environments*[]stringfalseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
Notifications[]NotificationTargettrueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

List alerts

res = client.alert.list(page=1, limit=50)data = res.datameta = res.meta

meta contains the pagination fields (page, limit, total_items, total_pages). Asking for a page past the last one returns an empty data array — not an error.

Lists the alerts in your project, paginated. You can narrow the results by searching the name, or by filtering on status, scope, or metric.

ParamTypeRequiredDescription
pagenumberfalse1-indexed page number (default 1)
Default: 1
limitnumberfalsePage size, max 100 (default 50)
Default: 50
searchstringfalseSubstring match on alert name (case-insensitive)
status'active' | 'paused'
"active" | "paused"
falseFilter by status — "active" or "paused"
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricstringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageOptional[int]false1-indexed page number (default 1)
Default: 1
limitOptional[int]falsePage size, max 100 (default 50)
Default: 50
searchOptional[str]falseSubstring match on alert name (case-insensitive)
statusOptional[str]
"active", "paused"
falseFilter by status — "active" or "paused"
scopeOptional[str]
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricOptional[str]falseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageIntegerfalse1-indexed page number (default 1)
Default: 1
limitIntegerfalsePage size, max 100 (default 50)
Default: 50
searchStringfalseSubstring match on alert name (case-insensitive)
statusString
"active", "paused"
falseFilter by status — "active" or "paused"
scopeString
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricStringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
Page*intfalse1-indexed page number (default 1)
Default: 1
Limit*intfalsePage size, max 100 (default 50)
Default: 50
Search*stringfalseSubstring match on alert name (case-insensitive)
Status*string
"active", "paused"
falseFilter by status — "active" or "paused"
Scope*string
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
Metric*stringfalseExact match on the metric key (e.g. "latency", "score:relevance")

Get an alert by id

fetched = client.alert.get(alert_id)

Get one alert by id

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Update an alert

Only the fields you send are updated — everything else stays the way it was. Handy for tweaking a threshold without rewriting the whole request.

updated = client.alert.update(    alert_id,    threshold=999,    description="updated description",)

Updates the alert. Only the fields you send are changed — anything you leave out stays the same. Pass `description: null` to clear the description.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
namestringfalseNew name. 1–255 characters.
descriptionstring | nullfalseNew description. Pass `null` to clear it. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseNew aggregation over the window.
metricstringfalseNew metric — a built-in metric or `score:<name>`.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseNew comparison between the aggregated metric and the threshold.
thresholdnumberfalseNew threshold.
unitstring | nullfalseNew display unit. Pass `null` to clear.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
falseNew look-back window in minutes.
cooldownMinutesnumberfalseNew cooldown between fires.
environmentsstring[]falseNew environments. Empty means evaluate every environment.
notificationsNotificationTarget[]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
nameOptional[str]falseNew name. 1–255 characters.
descriptionOptional[str]falseNew description. Pass `null` to clear it. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricOptional[object]falseNew metric — a built-in metric or `score:<name>`.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdOptional[float]falseNew threshold.
unitOptional[str]falseNew display unit. Pass `null` to clear.
window_minutesOptional[AlertConfigWindowMinutes]
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldown_minutesOptional[int]falseNew cooldown between fires.
environmentsOptional[list[str]]falseNew environments. Empty means evaluate every environment.
notificationsOptional[list[NotificationTargetInput]]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
nameStringfalseNew name. 1–255 characters.
descriptionStringfalseNew description. Pass `null` to clear it. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricStringfalseNew metric — a built-in metric or `score:<name>`.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdDoublefalseNew threshold.
unitStringfalseNew display unit. Pass `null` to clear.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldownMinutesIntegerfalseNew cooldown between fires.
environmentsList<String>falseNew environments. Empty means evaluate every environment.
notificationsList<NotificationTarget>falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
Name*stringfalseNew name. 1–255 characters.
Description*stringfalseNew description. Pass `null` to clear it. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseNew aggregation over the window.
Metric*stringfalseNew metric — a built-in metric or `score:<name>`.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseNew comparison between the aggregated metric and the threshold.
Threshold*float64falseNew threshold.
Unit*stringfalseNew display unit. Pass `null` to clear.
WindowMinutes*AlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
falseNew look-back window in minutes.
CooldownMinutes*intfalseNew cooldown between fires.
Environments*[]stringfalseNew environments. Empty means evaluate every environment.
Notifications*[]NotificationTargetfalseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

Pause and resume

pause() disables an alert without deleting it — useful during a maintenance window when you don't want false alarms. resume() turns it back on. Both are simple wrappers around the /toggle endpoint.

paused = client.alert.pause(alert_id)
resumed = client.alert.resume(alert_id)

Pause an alert without deleting its config. Convenience wrapper for `toggleAlert(alertId, false)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Re-enable a previously-paused alert. Convenience wrapper for `toggleAlert(alertId, true)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Delete an alert

result = client.alert.delete(alert_id)

Calling get() on the same id afterwards returns 404.

Delete an alert

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Complete example

Every step above, stitched together into one block you can copy and adapt. Fill in alert_id where a later step needs the id returned by create.

# 1. Set up the clientfrom browserstack_ai_sdk import AISDKclient = AISDK(    public_key=os.environ["AISDK_PUBLIC_KEY"],    secret_key=os.environ["AISDK_SECRET_KEY"],)# 2. Per-run variablesname = "High p95 latency on production traces"# 3. Create an alertalert = client.alert.create(    name=name,    scope="TRACE",    aggregation="AVG",    metric="latency",    operator="GT",    threshold=750,    window_minutes=5,    cooldown_minutes=10,    environments=["default"],    notifications=[        {            "channel": "webhook",            "enabled": True,            "config": {"url": "https://example.com/alerts/webhook"},        },    ],    description="all-fields alert",    unit="ms",)# 4. Grab the id for later stepsalert_id = alert.id# 5. List alertsres = client.alert.list(page=1, limit=50)data = res.datameta = res.meta# 6. Fetch it by idfetched = client.alert.get(alert_id)# 7. Update the thresholdupdated = client.alert.update(    alert_id,    threshold=999,    description="updated description",)# 8. Pause during maintenancepaused = client.alert.pause(alert_id)# 9. Resume when doneresumed = client.alert.resume(alert_id)# 10. Delete the alertresult = client.alert.delete(alert_id)

Setup

Put your public and secret keys in your environment, then create one SDK instance and reuse it for every call on this page.

import com.browserstack.aisdk.AISDK;import com.browserstack.aisdk.clients.alert.Alert;import com.browserstack.aisdk.clients.alert.AlertConfig;import com.browserstack.aisdk.clients.alert.AlertConfigAggregation;import com.browserstack.aisdk.clients.alert.AlertConfigOperator;import com.browserstack.aisdk.clients.alert.AlertConfigScope;import com.browserstack.aisdk.clients.alert.AlertConfigWindowMinutes;import com.browserstack.aisdk.clients.alert.CreateAlertBody;import com.browserstack.aisdk.clients.alert.DeleteAlertResponse;import com.browserstack.aisdk.clients.alert.ListAlertsParams;import com.browserstack.aisdk.clients.alert.ListAlertsResponse;import com.browserstack.aisdk.clients.alert.NotificationTarget;import com.browserstack.aisdk.clients.alert.NotificationTargetChannel;import com.browserstack.aisdk.clients.alert.PaginationMeta;import com.browserstack.aisdk.clients.alert.UpdateAlertBody;import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;AISDK sdk = AISDK.builder()    .publicKey(System.getenv("AISDK_PUBLIC_KEY"))    .secretKey(System.getenv("AISDK_SECRET_KEY"))    .build();Alert alerts = sdk.alert();

Create an alert

NotificationTarget webhook = new NotificationTarget();webhook.channel = NotificationTargetChannel.webhook;webhook.enabled = true;Map<String, Object> webhookConfig = new HashMap<>();webhookConfig.put("url", "https://example.com/sdk-test-webhook");webhook.config = webhookConfig;CreateAlertBody body = new CreateAlertBody();body.name = "High p95 latency on production traces";body.description = "Notify on-call when average trace latency exceeds 750 ms.";body.scope = AlertConfigScope.TRACE;body.aggregation = AlertConfigAggregation.AVG;body.metric = "latency";body.operator = AlertConfigOperator.GT;body.threshold = 750.0;body.windowMinutes = AlertConfigWindowMinutes.M_5;body.cooldownMinutes = 10;body.environments = Collections.singletonList("default");body.notifications = Collections.singletonList(webhook);AlertConfig alert = client.create(body);

The response includes everything the server saved — defaults it filled in for you, and the alert's id, which you'll use for every follow-up call.

Creates a new alert in your project. The server validates the window size, metric, environments, filter columns, and each notification target before saving.

ParamTypeRequiredDescription
namestringtrueA name for the alert. 1–255 characters.
descriptionstring | nullfalseOptional free-form description. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricstringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdnumberfalseThe value the metric is compared against.
unitstring | nullfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
trueHow far back to look when aggregating the metric.
cooldownMinutesnumberfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsstring[]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsNotificationTarget[]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
namestrtrueA name for the alert. 1–255 characters.
descriptionOptional[str]falseOptional free-form description. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricOptional[object]falseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdOptional[float]falseThe value the metric is compared against.
unitOptional[str]falseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
window_minutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldown_minutesOptional[int]falseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsOptional[list[str]]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationslist[NotificationTargetInput]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
nameStringtrueA name for the alert. 1–255 characters.
descriptionStringfalseOptional free-form description. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricStringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdDoublefalseThe value the metric is compared against.
unitStringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldownMinutesIntegerfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsList<String>falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsList<NotificationTarget>trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
NamestringtrueA name for the alert. 1–255 characters.
Description*stringfalseOptional free-form description. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
Metric*stringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
Threshold*float64falseThe value the metric is compared against.
Unit*stringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
WindowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
trueHow far back to look when aggregating the metric.
CooldownMinutes*intfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
Environments*[]stringfalseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
Notifications[]NotificationTargettrueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

List alerts

ListAlertsParams params = new ListAlertsParams();params.page = 1;params.limit = 50;ListAlertsResponse res = client.list(params);

meta contains the pagination fields (page, limit, totalItems, totalPages). Asking for a page past the last one returns an empty data list — not an error.

Lists the alerts in your project, paginated. You can narrow the results by searching the name, or by filtering on status, scope, or metric.

ParamTypeRequiredDescription
pagenumberfalse1-indexed page number (default 1)
Default: 1
limitnumberfalsePage size, max 100 (default 50)
Default: 50
searchstringfalseSubstring match on alert name (case-insensitive)
status'active' | 'paused'
"active" | "paused"
falseFilter by status — "active" or "paused"
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricstringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageOptional[int]false1-indexed page number (default 1)
Default: 1
limitOptional[int]falsePage size, max 100 (default 50)
Default: 50
searchOptional[str]falseSubstring match on alert name (case-insensitive)
statusOptional[str]
"active", "paused"
falseFilter by status — "active" or "paused"
scopeOptional[str]
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricOptional[str]falseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageIntegerfalse1-indexed page number (default 1)
Default: 1
limitIntegerfalsePage size, max 100 (default 50)
Default: 50
searchStringfalseSubstring match on alert name (case-insensitive)
statusString
"active", "paused"
falseFilter by status — "active" or "paused"
scopeString
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricStringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
Page*intfalse1-indexed page number (default 1)
Default: 1
Limit*intfalsePage size, max 100 (default 50)
Default: 50
Search*stringfalseSubstring match on alert name (case-insensitive)
Status*string
"active", "paused"
falseFilter by status — "active" or "paused"
Scope*string
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
Metric*stringfalseExact match on the metric key (e.g. "latency", "score:relevance")

Get an alert by id

AlertConfig fetched = client.get(alertId);

Get one alert by id

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Update an alert

Only the fields you send are updated — everything else stays the way it was. Handy for tweaking a threshold without rewriting the whole request.

UpdateAlertBody update = new UpdateAlertBody();update.threshold = 999.0;update.description = "updated description";AlertConfig updated = client.update(alertId, update);

Updates the alert. Only the fields you send are changed — anything you leave out stays the same. Pass `description: null` to clear the description.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
namestringfalseNew name. 1–255 characters.
descriptionstring | nullfalseNew description. Pass `null` to clear it. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseNew aggregation over the window.
metricstringfalseNew metric — a built-in metric or `score:<name>`.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseNew comparison between the aggregated metric and the threshold.
thresholdnumberfalseNew threshold.
unitstring | nullfalseNew display unit. Pass `null` to clear.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
falseNew look-back window in minutes.
cooldownMinutesnumberfalseNew cooldown between fires.
environmentsstring[]falseNew environments. Empty means evaluate every environment.
notificationsNotificationTarget[]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
nameOptional[str]falseNew name. 1–255 characters.
descriptionOptional[str]falseNew description. Pass `null` to clear it. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricOptional[object]falseNew metric — a built-in metric or `score:<name>`.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdOptional[float]falseNew threshold.
unitOptional[str]falseNew display unit. Pass `null` to clear.
window_minutesOptional[AlertConfigWindowMinutes]
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldown_minutesOptional[int]falseNew cooldown between fires.
environmentsOptional[list[str]]falseNew environments. Empty means evaluate every environment.
notificationsOptional[list[NotificationTargetInput]]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
nameStringfalseNew name. 1–255 characters.
descriptionStringfalseNew description. Pass `null` to clear it. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricStringfalseNew metric — a built-in metric or `score:<name>`.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdDoublefalseNew threshold.
unitStringfalseNew display unit. Pass `null` to clear.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldownMinutesIntegerfalseNew cooldown between fires.
environmentsList<String>falseNew environments. Empty means evaluate every environment.
notificationsList<NotificationTarget>falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
Name*stringfalseNew name. 1–255 characters.
Description*stringfalseNew description. Pass `null` to clear it. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseNew aggregation over the window.
Metric*stringfalseNew metric — a built-in metric or `score:<name>`.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseNew comparison between the aggregated metric and the threshold.
Threshold*float64falseNew threshold.
Unit*stringfalseNew display unit. Pass `null` to clear.
WindowMinutes*AlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
falseNew look-back window in minutes.
CooldownMinutes*intfalseNew cooldown between fires.
Environments*[]stringfalseNew environments. Empty means evaluate every environment.
Notifications*[]NotificationTargetfalseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

Pause and resume

pause() disables an alert without deleting it — useful during a maintenance window when you don't want false alarms. resume() turns it back on. Both are simple wrappers around the /toggle endpoint.

AlertConfig paused = client.pause(alertId);
AlertConfig resumed = client.resume(alertId);

Pause an alert without deleting its config. Convenience wrapper for `toggleAlert(alertId, false)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Re-enable a previously-paused alert. Convenience wrapper for `toggleAlert(alertId, true)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Delete an alert

DeleteAlertResponse result = client.delete(alertId);

Calling get() on the same id afterwards throws (mapped from HTTP 404).

Delete an alert

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Complete example

Every step above, stitched together into one block you can copy and adapt. Fill in alertId where a later step needs the id returned by create.

// 1. Set up the SDKimport com.browserstack.aisdk.AISDK;import com.browserstack.aisdk.clients.alert.Alert;import com.browserstack.aisdk.clients.alert.AlertConfig;import com.browserstack.aisdk.clients.alert.AlertConfigAggregation;import com.browserstack.aisdk.clients.alert.AlertConfigOperator;import com.browserstack.aisdk.clients.alert.AlertConfigScope;import com.browserstack.aisdk.clients.alert.AlertConfigWindowMinutes;import com.browserstack.aisdk.clients.alert.CreateAlertBody;import com.browserstack.aisdk.clients.alert.DeleteAlertResponse;import com.browserstack.aisdk.clients.alert.ListAlertsParams;import com.browserstack.aisdk.clients.alert.ListAlertsResponse;import com.browserstack.aisdk.clients.alert.NotificationTarget;import com.browserstack.aisdk.clients.alert.NotificationTargetChannel;import com.browserstack.aisdk.clients.alert.PaginationMeta;import com.browserstack.aisdk.clients.alert.UpdateAlertBody;import java.util.Collections;import java.util.HashMap;import java.util.List;import java.util.Map;AISDK sdk = AISDK.builder()    .publicKey(System.getenv("AISDK_PUBLIC_KEY"))    .secretKey(System.getenv("AISDK_SECRET_KEY"))    .build();Alert alerts = sdk.alert();// 2. Per-run variablesString name = "High p95 latency on production traces";// 3. Create an alertNotificationTarget webhook = new NotificationTarget();webhook.channel = NotificationTargetChannel.webhook;webhook.enabled = true;Map<String, Object> webhookConfig = new HashMap<>();webhookConfig.put("url", "https://example.com/sdk-test-webhook");webhook.config = webhookConfig;CreateAlertBody body = new CreateAlertBody();body.name = "High p95 latency on production traces";body.description = "Notify on-call when average trace latency exceeds 750 ms.";body.scope = AlertConfigScope.TRACE;body.aggregation = AlertConfigAggregation.AVG;body.metric = "latency";body.operator = AlertConfigOperator.GT;body.threshold = 750.0;body.windowMinutes = AlertConfigWindowMinutes.M_5;body.cooldownMinutes = 10;body.environments = Collections.singletonList("default");body.notifications = Collections.singletonList(webhook);AlertConfig alert = client.create(body);// 4. Grab the id for later stepsString alertId = alert.id;// 5. List alertsListAlertsParams params = new ListAlertsParams();params.page = 1;params.limit = 50;ListAlertsResponse res = client.list(params);// 6. Fetch it by idAlertConfig fetched = client.get(alertId);// 7. Update the thresholdUpdateAlertBody update = new UpdateAlertBody();update.threshold = 999.0;update.description = "updated description";AlertConfig updated = client.update(alertId, update);// 8. Pause during maintenanceAlertConfig paused = client.pause(alertId);// 9. Resume when doneAlertConfig resumed = client.resume(alertId);// 10. Delete the alertDeleteAlertResponse result = client.delete(alertId);

Setup

Put your public and secret keys in your environment, then create one SDK instance and reuse it for every call on this page.

import (	"context"	"log"	"os"	aisdk "github.com/browserstack/ai-sdk-go")sdk, err := aisdk.New(aisdk.WithCredentials(	os.Getenv("AISDK_PUBLIC_KEY"),	os.Getenv("AISDK_SECRET_KEY"),))if err != nil {	log.Fatalf("aisdk.New: %v", err)}

Create an alert

scope := AlertConfigScope("TRACE")aggregation := AlertConfigAggregation("AVG")metric := "latency"operator := AlertConfigOperator("GT")threshold := 750.0description := "Notify on-call when average trace latency exceeds 750 ms."cooldownMinutes := 10environments := []string{"default"}body := &CreateAlertBody{	Name:            "High p95 latency on production traces",	Description:     &description,	Scope:           &scope,	Aggregation:     &aggregation,	Metric:          &metric,	Operator:        &operator,	Threshold:       &threshold,	WindowMinutes:   5,	CooldownMinutes: &cooldownMinutes,	Environments:    &environments,	Notifications: []NotificationTarget{		{			Channel: "webhook",			Enabled: true,			Config: map[string]interface{}{				"url": "https://example.com/sdk-test-webhook",			},		},	},}alert, err := client.Create(context.Background(), body)

The response includes everything the server saved — defaults it filled in for you, and the alert's ID, which you'll use for every follow-up call.

Creates a new alert in your project. The server validates the window size, metric, environments, filter columns, and each notification target before saving.

ParamTypeRequiredDescription
namestringtrueA name for the alert. 1–255 characters.
descriptionstring | nullfalseOptional free-form description. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricstringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdnumberfalseThe value the metric is compared against.
unitstring | nullfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
trueHow far back to look when aggregating the metric.
cooldownMinutesnumberfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsstring[]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsNotificationTarget[]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
namestrtrueA name for the alert. 1–255 characters.
descriptionOptional[str]falseOptional free-form description. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricOptional[object]falseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdOptional[float]falseThe value the metric is compared against.
unitOptional[str]falseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
window_minutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldown_minutesOptional[int]falseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsOptional[list[str]]falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationslist[NotificationTargetInput]trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
nameStringtrueA name for the alert. 1–255 characters.
descriptionStringfalseOptional free-form description. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
metricStringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
thresholdDoublefalseThe value the metric is compared against.
unitStringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
trueHow far back to look when aggregating the metric.
cooldownMinutesIntegerfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
environmentsList<String>falseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
notificationsList<NotificationTarget>trueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
NamestringtrueA name for the alert. 1–255 characters.
Description*stringfalseOptional free-form description. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Default: "TRACE"
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseHow the metric is aggregated over the window before it's compared to the threshold. Required in Condition mode; derived from the SQL in SQL mode.
Metric*stringfalseA built-in metric, or `score:<name>` for a custom score. Required in Condition mode.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseThe comparison between the aggregated metric and the threshold. Required in Condition mode.
Threshold*float64falseThe value the metric is compared against.
Unit*stringfalseAn optional display unit, like `ms` or `USD`. Doesn't affect evaluation.
WindowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
trueHow far back to look when aggregating the metric.
CooldownMinutes*intfalseMinimum time between fires. Keeps you from getting a wall of duplicate notifications.
Default: 15
Environments*[]stringfalseThe environments the alert runs on. Leave empty to evaluate every environment.
Default: []
Notifications[]NotificationTargettrueOne or more places to send the notification when the alert fires — webhook, email, or Slack.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseAn optional filter to narrow what the alert evaluates. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

List alerts

page := 1limit := 1params := &ListAlertsParams{	Page:  &page,	Limit: &limit,}res, err := client.List(context.Background(), params)

Meta contains the pagination fields (Page, Limit, TotalItems, TotalPages). Asking for a page past the last one returns an empty Data slice — not an error.

Lists the alerts in your project, paginated. You can narrow the results by searching the name, or by filtering on status, scope, or metric.

ParamTypeRequiredDescription
pagenumberfalse1-indexed page number (default 1)
Default: 1
limitnumberfalsePage size, max 100 (default 50)
Default: 50
searchstringfalseSubstring match on alert name (case-insensitive)
status'active' | 'paused'
"active" | "paused"
falseFilter by status — "active" or "paused"
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricstringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageOptional[int]false1-indexed page number (default 1)
Default: 1
limitOptional[int]falsePage size, max 100 (default 50)
Default: 50
searchOptional[str]falseSubstring match on alert name (case-insensitive)
statusOptional[str]
"active", "paused"
falseFilter by status — "active" or "paused"
scopeOptional[str]
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricOptional[str]falseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
pageIntegerfalse1-indexed page number (default 1)
Default: 1
limitIntegerfalsePage size, max 100 (default 50)
Default: 50
searchStringfalseSubstring match on alert name (case-insensitive)
statusString
"active", "paused"
falseFilter by status — "active" or "paused"
scopeString
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
metricStringfalseExact match on the metric key (e.g. "latency", "score:relevance")
ParamTypeRequiredDescription
Page*intfalse1-indexed page number (default 1)
Default: 1
Limit*intfalsePage size, max 100 (default 50)
Default: 50
Search*stringfalseSubstring match on alert name (case-insensitive)
Status*string
"active", "paused"
falseFilter by status — "active" or "paused"
Scope*string
"TRACE", "SESSION"
falseFilter by scope — "TRACE" or "SESSION"
Metric*stringfalseExact match on the metric key (e.g. "latency", "score:relevance")

Get an alert by id

fetched, err := client.Get(context.Background(), alertID)

Get one alert by id

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Update an alert

Only the fields you send are updated — everything else stays the way it was. Handy for tweaking a threshold without rewriting the whole request.

threshold := 999.0description := "updated description"body := &UpdateAlertBody{	Threshold:   &threshold,	Description: &description,}updated, err := client.Update(context.Background(), alertID, body)

Updates the alert. Only the fields you send are changed — anything you leave out stays the same. Pass `description: null` to clear the description.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
namestringfalseNew name. 1–255 characters.
descriptionstring | nullfalseNew description. Pass `null` to clear it. Up to 500 characters.
scope'TRACE' | 'SESSION'
"TRACE" | "SESSION"
falseWhether the alert watches trace metrics or session metrics.
aggregationstring
"AVG" | "MIN" | "MAX" | "P50" | "P95" | "P99" | "SUM" | "COUNT"
falseNew aggregation over the window.
metricstringfalseNew metric — a built-in metric or `score:<name>`.
operatorstring
"GT" | "LT" | "GTE" | "LTE"
falseNew comparison between the aggregated metric and the threshold.
thresholdnumberfalseNew threshold.
unitstring | nullfalseNew display unit. Pass `null` to clear.
windowMinutesnumber
5 | 10 | 15 | 30 | 60 | 360 | 720 | 1440 | 4320 | 10080
falseNew look-back window in minutes.
cooldownMinutesnumberfalseNew cooldown between fires.
environmentsstring[]falseNew environments. Empty means evaluate every environment.
notificationsNotificationTarget[]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterRecord<string, unknown> | nullfalseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
nameOptional[str]falseNew name. 1–255 characters.
descriptionOptional[str]falseNew description. Pass `null` to clear it. Up to 500 characters.
scopeOptional[AlertConfigScope]
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationOptional[AlertConfigAggregation]
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricOptional[object]falseNew metric — a built-in metric or `score:<name>`.
operatorOptional[AlertConfigOperator]
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdOptional[float]falseNew threshold.
unitOptional[str]falseNew display unit. Pass `null` to clear.
window_minutesOptional[AlertConfigWindowMinutes]
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldown_minutesOptional[int]falseNew cooldown between fires.
environmentsOptional[list[str]]falseNew environments. Empty means evaluate every environment.
notificationsOptional[list[NotificationTargetInput]]falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterOptional[dict[str, object]]falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
nameStringfalseNew name. 1–255 characters.
descriptionStringfalseNew description. Pass `null` to clear it. Up to 500 characters.
scopeAlertConfigScope
AlertConfigScope.TRACE, AlertConfigScope.SESSION
falseWhether the alert watches trace metrics or session metrics.
aggregationAlertConfigAggregation
AlertConfigAggregation.AVG, AlertConfigAggregation.MIN, AlertConfigAggregation.MAX, AlertConfigAggregation.P50, AlertConfigAggregation.P95, AlertConfigAggregation.P99, AlertConfigAggregation.SUM, AlertConfigAggregation.COUNT
falseNew aggregation over the window.
metricStringfalseNew metric — a built-in metric or `score:<name>`.
operatorAlertConfigOperator
AlertConfigOperator.GT, AlertConfigOperator.LT, AlertConfigOperator.GTE, AlertConfigOperator.LTE
falseNew comparison between the aggregated metric and the threshold.
thresholdDoublefalseNew threshold.
unitStringfalseNew display unit. Pass `null` to clear.
windowMinutesAlertConfigWindowMinutes
AlertConfigWindowMinutes.M_5, AlertConfigWindowMinutes.M_10, AlertConfigWindowMinutes.M_15, AlertConfigWindowMinutes.M_30, AlertConfigWindowMinutes.M_60, AlertConfigWindowMinutes.M_360, AlertConfigWindowMinutes.M_720, AlertConfigWindowMinutes.M_1440, AlertConfigWindowMinutes.M_4320, AlertConfigWindowMinutes.M_10080
falseNew look-back window in minutes.
cooldownMinutesIntegerfalseNew cooldown between fires.
environmentsList<String>falseNew environments. Empty means evaluate every environment.
notificationsList<NotificationTarget>falseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
filterMap<String, Object>falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
Name*stringfalseNew name. 1–255 characters.
Description*stringfalseNew description. Pass `null` to clear it. Up to 500 characters.
Scope*AlertConfigScope
AlertConfigScopeTRACE, AlertConfigScopeSESSION
falseWhether the alert watches trace metrics or session metrics.
Aggregation*AlertConfigAggregation
AlertConfigAggregationAVG, AlertConfigAggregationMIN, AlertConfigAggregationMAX, AlertConfigAggregationP50, AlertConfigAggregationP95, AlertConfigAggregationP99, AlertConfigAggregationSUM, AlertConfigAggregationCOUNT
falseNew aggregation over the window.
Metric*stringfalseNew metric — a built-in metric or `score:<name>`.
Operator*AlertConfigOperator
AlertConfigOperatorGT, AlertConfigOperatorLT, AlertConfigOperatorGTE, AlertConfigOperatorLTE
falseNew comparison between the aggregated metric and the threshold.
Threshold*float64falseNew threshold.
Unit*stringfalseNew display unit. Pass `null` to clear.
WindowMinutes*AlertConfigWindowMinutes
AlertConfigWindowMinutesM_5, AlertConfigWindowMinutesM_10, AlertConfigWindowMinutesM_15, AlertConfigWindowMinutesM_30, AlertConfigWindowMinutesM_60, AlertConfigWindowMinutesM_360, AlertConfigWindowMinutesM_720, AlertConfigWindowMinutesM_1440, AlertConfigWindowMinutesM_4320, AlertConfigWindowMinutesM_10080
falseNew look-back window in minutes.
CooldownMinutes*intfalseNew cooldown between fires.
Environments*[]stringfalseNew environments. Empty means evaluate every environment.
Notifications*[]NotificationTargetfalseNew notification targets. Passing an empty array isn't supported — leave the field out to keep what's already there.
Notifications.channel"webhook" | "email" | "slack"trueHow the notification is delivered.
Notifications.enabledbooleantrueWhether this channel is active. Disabled channels are kept but skipped when the alert fires.
Default: true
Notifications.configobjecttrueChannel-specific settings (the shape depends on `channel`).
Filtermap[string]interface{}falseNew filter. `null` means "evaluate everything in scope." A non-null value has a `mode` field that's either `"conditions"` or `"sql"`.

Pause and resume

Pause() disables an alert without deleting it — useful during a maintenance window when you don't want false alarms. Resume() turns it back on. Both are simple wrappers around the /toggle endpoint.

paused, err := client.Pause(context.Background(), alertID)
resumed, err := client.Resume(context.Background(), alertID)

Pause an alert without deleting its config. Convenience wrapper for `toggleAlert(alertId, false)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Re-enable a previously-paused alert. Convenience wrapper for `toggleAlert(alertId, true)`.

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id (returned from `create()`).
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id (returned from `create()`).

Delete an alert

result, err := client.Delete(context.Background(), alertID)

Calling Get() on the same id afterwards returns an error mapped from HTTP 404.

Delete an alert

ParamTypeRequiredDescription
alertIdstringtrueThe alert's id
ParamTypeRequiredDescription
alert_idstrtrueThe alert's id
ParamTypeRequiredDescription
alertIdStringtrueThe alert's id
ParamTypeRequiredDescription
alertIdstringtrueThe alert's id

Complete example

Every step above, stitched together into one block you can copy and adapt. Fill in alertID where a later step needs the id returned by Create.

// 1. Set up the SDKimport (	"context"	"log"	"os"	aisdk "github.com/browserstack/ai-sdk-go")sdk, err := aisdk.New(aisdk.WithCredentials(	os.Getenv("AISDK_PUBLIC_KEY"),	os.Getenv("AISDK_SECRET_KEY"),))if err != nil {	log.Fatalf("aisdk.New: %v", err)}// 2. Per-run variablesname := "High p95 latency on production traces"// 3. Create an alertscope := AlertConfigScope("TRACE")aggregation := AlertConfigAggregation("AVG")metric := "latency"operator := AlertConfigOperator("GT")threshold := 750.0description := "Notify on-call when average trace latency exceeds 750 ms."cooldownMinutes := 10environments := []string{"default"}body := &CreateAlertBody{	Name:            "High p95 latency on production traces",	Description:     &description,	Scope:           &scope,	Aggregation:     &aggregation,	Metric:          &metric,	Operator:        &operator,	Threshold:       &threshold,	WindowMinutes:   5,	CooldownMinutes: &cooldownMinutes,	Environments:    &environments,	Notifications: []NotificationTarget{		{			Channel: "webhook",			Enabled: true,			Config: map[string]interface{}{				"url": "https://example.com/sdk-test-webhook",			},		},	},}alert, err := client.Create(context.Background(), body)// 4. Grab the id for later stepsalertID := alert.Id// 5. List alertspage := 1limit := 1params := &ListAlertsParams{	Page:  &page,	Limit: &limit,}res, err := client.List(context.Background(), params)// 6. Fetch it by idfetched, err := client.Get(context.Background(), alertID)// 7. Update the thresholdthreshold := 999.0description := "updated description"body := &UpdateAlertBody{	Threshold:   &threshold,	Description: &description,}updated, err := client.Update(context.Background(), alertID, body)// 8. Pause during maintenancepaused, err := client.Pause(context.Background(), alertID)// 9. Resume when doneresumed, err := client.Resume(context.Background(), alertID)// 10. Delete the alertresult, err := client.Delete(context.Background(), alertID)

Where to view results

Fired alerts show up in the dashboard under Project → Alerts on the Alert Events tab, and they also post to any notification channels you've set up (webhook, email, or Slack). See the Alerts UI guide for how the event lifecycle (FIRING → ACKNOWLEDGED → RESOLVED) works.