Launch Week 3: Five days of launches

Scheduled Alerts

Overview

The Confident AI SDK exposes every Scheduled Alert method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.

Methods

List Scheduled Alerts

Lists the scheduled alerts in your Confident AI project one page at a time, ordered by name, as summary rows.

from confident_ai import ConfidentAI
from confident_ai.scheduled_alerts import AlertDataModel

client = ConfidentAI()

result = client.scheduled_alerts.list(
    page=1,
    page_size=25,
    data_model=AlertDataModel.TRACE,
    enabled="true",
)

For async mode, call a_list and await it as shown below:

result = await client.scheduled_alerts.a_list(...)

Parameters

ParameterTypeDescription
pageOptional[int]The page of scheduled alerts to return. Defaults to 1.
page_sizeOptional[int]The number of scheduled alerts per page, at most 100. Defaults to 25.
data_modelOptional[AlertDataModel]Returns only alerts measuring this kind of item. Omit to return all of them. See AlertDataModel.
enabledOptional[Literal['true', 'false']]Returns only alerts whose schedule is running when true, or only the paused ones when false. Omit to return both.

Returns

This method returns an object of type ScheduledAlertList.

Create Scheduled Alert

Creates an alert that re-runs an aggregate query on a schedule and notifies when the result crosses the threshold, and returns its id. Notifications are delivered through the project's integrations that have alerting enabled for the alert's severity, so an alert in a project with no such integration still evaluates but reaches nobody.

from confident_ai import ConfidentAI
from confident_ai.scheduled_alerts import AlertDataModel
from confident_ai.scheduled_alerts import AlertSeverity
from confident_ai.scheduled_alerts import AlertThresholdDirection
from confident_ai.scheduled_alerts import AlertThresholdSettings
from confident_ai.common import ScheduleIntervalUnit
from confident_ai.common import ScheduleRecurrenceType

client = ConfidentAI()

result = client.scheduled_alerts.create(
    name="Trace error rate spike",
    data_model=AlertDataModel.TRACE,
    aggregation="ERROR_RATE",
    threshold_settings=AlertThresholdSettings(
        value=0.05,
        direction=AlertThresholdDirection.ABOVE
    ),
    recurrence=ScheduleRecurrenceType.ONCE,
    repeat_every=1,
    repeat_unit=ScheduleIntervalUnit.MINUTE,
    start_at="2025-02-01T09:00:00+00:00",
    max_runs=12,
    end_at="2025-12-31T23:59:59+00:00",
    description="Errors above 5% over the last hour.",
    filters={
        "operator": "AND",
        "groups": [
            {
                "operator": "AND",
                "filters": [
                    {
                        "category": "Trace Name",
                        "condition": "Is",
                        "value": "checkout"
                    }
                ]
            }
        ]
    },
    severity=AlertSeverity.CRITICAL,
    enabled=True,
)

For async mode, call a_create and await it as shown below:

result = await client.scheduled_alerts.a_create(...)

Parameters

ParameterTypeDescription
namestrRequired. A name for the alert, shown in the notification.
data_modelAlertDataModelRequired. See AlertDataModel.
aggregationstrRequired. What to measure, as an aggregation token. Which tokens are valid depends on dataModel: TRACE accepts COUNT, ERROR_RATE, PASS_RATE, UNIQUE_END_USERS, UNIQUE_THREADS, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, INPUT_TOKENS, OUTPUT_TOKENS, TOTAL_TOKENS, UNIQUE_METADATA_VALUES; LLM_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, INPUT_TOKENS, OUTPUT_TOKENS, TOTAL_TOKENS, UNIQUE_METADATA_VALUES; AGENT_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; RETRIEVER_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; TOOL_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; CUSTOM_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; THREAD accepts COUNT, UNIQUE_USERS, UNIQUE_METADATA_VALUES.
threshold_settingsAlertThresholdSettingsRequired. See AlertThresholdSettings.
recurrenceOptional[ScheduleRecurrenceType]See ScheduleRecurrenceType.
repeat_everyOptional[int]How many repeatUnits apart the runs are, for an INTERVAL schedule. Send null to clear it.
repeat_unitOptional[ScheduleIntervalUnit]The unit repeatEvery counts, for an INTERVAL schedule. Send null to clear it. See ScheduleIntervalUnit.
start_atOptional[str]When the schedule first runs, as an ISO 8601 datetime. Send null to start it immediately.
max_runsOptional[int]How many times the schedule runs before it stops. Send null to let it run indefinitely.
end_atOptional[str]When the schedule stops running, as an ISO 8601 datetime. Send null to leave it open-ended.
descriptionOptional[str]What the alert means and what to do about it, included in the notification. Send null to clear it.
filtersOptional[FilterSet]Narrows what the alert measures over, so an alert can watch one route rather than the whole project. Send null to clear the filters and measure everything. See FilterSet.
severityOptional[AlertSeverity]See AlertSeverity.
enabledOptional[bool]Whether the schedule runs. Defaults to true.

Returns

This method returns an object of type ScheduledAlertRef.

Get Scheduled Alert

Retrieves a scheduled alert by id, with its aggregation, filters, threshold, severity and schedule state including how many times it has run.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.scheduled_alerts.get(
    scheduled_alert_id="<SCHEDULED-ALERT-ID>",
)

For async mode, call a_get and await it as shown below:

result = await client.scheduled_alerts.a_get(...)

Parameters

ParameterTypeDescription
scheduled_alert_idstrRequired. The id of the scheduled alert.

Returns

This method returns an object of type ScheduledAlert.

Update Scheduled Alert

Updates a scheduled alert and returns it. Only the fields you send are changed; omitting a field leaves it untouched, and sending null clears it. Because each dataModel accepts a different set of aggregations, send aggregation alongside dataModel when moving an alert between data models.

from confident_ai import ConfidentAI
from confident_ai.scheduled_alerts import AlertDataModel
from confident_ai.scheduled_alerts import AlertSeverity
from confident_ai.scheduled_alerts import AlertThresholdDirection
from confident_ai.scheduled_alerts import AlertThresholdSettings
from confident_ai.common import ScheduleIntervalUnit
from confident_ai.common import ScheduleRecurrenceType

client = ConfidentAI()

result = client.scheduled_alerts.update(
    scheduled_alert_id="<SCHEDULED-ALERT-ID>",
    recurrence=ScheduleRecurrenceType.ONCE,
    repeat_every=1,
    repeat_unit=ScheduleIntervalUnit.MINUTE,
    start_at="2025-02-01T09:00:00+00:00",
    max_runs=12,
    end_at="2025-12-31T23:59:59+00:00",
    description="Errors above 5% over the last hour.",
    filters={
        "operator": "AND",
        "groups": [
            {
                "operator": "AND",
                "filters": [
                    {
                        "category": "Trace Name",
                        "condition": "Is",
                        "value": "checkout"
                    }
                ]
            }
        ]
    },
    severity=AlertSeverity.CRITICAL,
    name="Trace error rate spike",
    data_model=AlertDataModel.TRACE,
    aggregation="ERROR_RATE",
    threshold_settings=AlertThresholdSettings(
        value=0.05,
        direction=AlertThresholdDirection.ABOVE
    ),
    enabled=False,
)

For async mode, call a_update and await it as shown below:

result = await client.scheduled_alerts.a_update(...)

Parameters

ParameterTypeDescription
scheduled_alert_idstrRequired. The id of the scheduled alert.
recurrenceOptional[ScheduleRecurrenceType]See ScheduleRecurrenceType.
repeat_everyOptional[int]How many repeatUnits apart the runs are, for an INTERVAL schedule. Send null to clear it.
repeat_unitOptional[ScheduleIntervalUnit]The unit repeatEvery counts, for an INTERVAL schedule. Send null to clear it. See ScheduleIntervalUnit.
start_atOptional[str]When the schedule first runs, as an ISO 8601 datetime. Send null to start it immediately.
max_runsOptional[int]How many times the schedule runs before it stops. Send null to let it run indefinitely.
end_atOptional[str]When the schedule stops running, as an ISO 8601 datetime. Send null to leave it open-ended.
descriptionOptional[str]What the alert means and what to do about it, included in the notification. Send null to clear it.
filtersOptional[FilterSet]Narrows what the alert measures over, so an alert can watch one route rather than the whole project. Send null to clear the filters and measure everything. See FilterSet.
severityOptional[AlertSeverity]See AlertSeverity.
nameOptional[str]A new name for the alert, shown in the notification.
data_modelOptional[AlertDataModel]See AlertDataModel.
aggregationOptional[str]What to measure, as an aggregation token. Which tokens are valid depends on dataModel: TRACE accepts COUNT, ERROR_RATE, PASS_RATE, UNIQUE_END_USERS, UNIQUE_THREADS, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, INPUT_TOKENS, OUTPUT_TOKENS, TOTAL_TOKENS, UNIQUE_METADATA_VALUES; LLM_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, INPUT_TOKENS, OUTPUT_TOKENS, TOTAL_TOKENS, UNIQUE_METADATA_VALUES; AGENT_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; RETRIEVER_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; TOOL_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; CUSTOM_SPAN accepts COUNT, AVG_LATENCY, P50_LATENCY, P90_LATENCY, P99_LATENCY, ERROR_RATE, ERROR_COUNT, INPUT_COST, OUTPUT_COST, TOTAL_COST, AVG_COST, UNIQUE_METADATA_VALUES; THREAD accepts COUNT, UNIQUE_USERS, UNIQUE_METADATA_VALUES.
threshold_settingsOptional[AlertThresholdSettings]See AlertThresholdSettings.
enabledOptional[bool]Whether the schedule runs. An alert whose run limit or end date has passed cannot be re-enabled without also moving maxRuns or endAt.

Returns

This method returns an object of type ScheduledAlert.

Delete Scheduled Alert

Permanently deletes a scheduled alert and unregisters its next run. To stop an alert temporarily, update it with enabled set to false instead. This action cannot be undone.

from confident_ai import ConfidentAI

client = ConfidentAI()

result = client.scheduled_alerts.delete(
    scheduled_alert_id="<SCHEDULED-ALERT-ID>",
)

For async mode, call a_delete and await it as shown below:

result = await client.scheduled_alerts.a_delete(...)

Parameters

ParameterTypeDescription
scheduled_alert_idstrRequired. The id of the scheduled alert.

Returns

This method returns an object of type ScheduledAlertRef.

Types

AlertDataModel

What kind of production item an alert measures over. TRACE and SPAN alerts aggregate single requests; THREAD alerts aggregate conversations.

class AlertDataModel(Enum):
    TRACE = "TRACE"
    SPAN = "SPAN"
    LLM_SPAN = "LLM_SPAN"
    AGENT_SPAN = "AGENT_SPAN"
    RETRIEVER_SPAN = "RETRIEVER_SPAN"
    TOOL_SPAN = "TOOL_SPAN"
    CUSTOM_SPAN = "CUSTOM_SPAN"
    THREAD = "THREAD"

TRACE · SPAN · LLM_SPAN · AGENT_SPAN · RETRIEVER_SPAN · TOOL_SPAN · CUSTOM_SPAN · THREAD

AlertSeverity

How urgent the alert is. It also decides who hears about it: an integration receives an alert only when it subscribes to that severity.

class AlertSeverity(Enum):
    CRITICAL = "CRITICAL"
    ERROR = "ERROR"
    WARNING = "WARNING"
    INFO = "INFO"

CRITICAL · ERROR · WARNING · INFO

AlertThresholdDirection

Whether the alert fires when the measured value rises above the threshold or falls below it.

class AlertThresholdDirection(Enum):
    ABOVE = "above"
    BELOW = "below"

ABOVE · BELOW

AlertThresholdSettings

When the alert fires. Latency is compared in seconds, cost in USD, and rates such as ERROR_RATE as fractions between 0 and 1.

class AlertThresholdSettings:
    value: float
    direction: AlertThresholdDirection

valuefloatRequired

The number the measured value is compared against.

Example: 0.05

directionAlertThresholdDirectionRequired

FilterSet

A set of filter groups combined by a top-level operator. Each group combines its filter rows by its own operator, and each row matches one property, such as Name or User Id, against a value with a condition such as Is or Contains.

class FilterSet:
    operator: Literal["AND", "OR"]
    groups: List[FilterSetGroup]

operatorLiteral["AND", "OR"]Required

groupsList[FilterSetGroup]Required

ScheduleIntervalUnit

The unit repeatEvery counts for an INTERVAL schedule.

class ScheduleIntervalUnit(Enum):
    MINUTE = "MINUTE"
    HOUR = "HOUR"
    DAY = "DAY"
    WEEK = "WEEK"
    MONTH = "MONTH"

MINUTE · HOUR · DAY · WEEK · MONTH

ScheduleRecurrenceType

How often a schedule fires: ONCE runs a single time at startAt, INTERVAL repeats every repeatEvery repeatUnits.

class ScheduleRecurrenceType(Enum):
    ONCE = "ONCE"
    INTERVAL = "INTERVAL"

ONCE · INTERVAL

ScheduledAlert

An alert that re-runs an aggregate query on a schedule and notifies when the result crosses its threshold.

class ScheduledAlert:
    id: str
    name: str
    description: Optional[str]
    data_model: AlertDataModel = Field(alias="dataModel")
    aggregation: str
    filters: FilterSet
    threshold_settings: AlertThresholdSettings = Field(alias="thresholdSettings")
    severity: AlertSeverity
    schedule_settings: Optional[ScheduledAlertScheduleSettings] = Field(alias="scheduleSettings")

idstrRequired

The id of the scheduled alert, generated by Confident AI.

Example: "<SCHEDULED-ALERT-ID>"

namestrRequired

The name of the alert, shown in the notification.

Example: "Trace error rate spike"

descriptionOptional[str]Required

What the alert means and what to do about it, or null when it has no description.

Example: "Errors above 5% over the last hour."

data_modelAlertDataModelRequired

aggregationstrRequired

What the alert measures, as an aggregation token.

Example: "ERROR_RATE"

filtersFilterSetRequired

threshold_settingsAlertThresholdSettingsRequired

severityAlertSeverityRequired

schedule_settingsOptional[ScheduledAlertScheduleSettings]Required

ScheduledAlertList

One page of scheduled alerts, with the total across all pages.

class ScheduledAlertList:
    scheduled_alerts: List[ScheduledAlertSummary] = Field(alias="scheduledAlerts")
    total_scheduled_alerts: int = Field(alias="totalScheduledAlerts")
    page: int
    page_size: int = Field(alias="pageSize")

scheduled_alertsList[ScheduledAlertSummary]Required

The scheduled alerts for the current page, ordered by name.

See ScheduledAlertSummary.

total_scheduled_alertsintRequired

The total number of scheduled alerts matching the filters.

Example: 7

pageintRequired

The page this response covers.

Example: 1

page_sizeintRequired

The number of scheduled alerts per page.

Example: 25

ScheduledAlertRef

A reference to a scheduled alert by its id.

class ScheduledAlertRef:
    id: str

idstrRequired

The id of the scheduled alert, generated by Confident AI.

Example: "<SCHEDULED-ALERT-ID>"

ScheduledAlertScheduleSettings

The alert's cadence together with its run history.

class ScheduledAlertScheduleSettings:
    recurrence: ScheduleRecurrenceType
    repeat_every: Optional[int] = Field(alias="repeatEvery")
    repeat_unit: Optional[ScheduleIntervalUnit] = Field(alias="repeatUnit")
    start_at: Optional[str] = Field(alias="startAt")
    end_at: Optional[str] = Field(alias="endAt")
    max_runs: Optional[int] = Field(alias="maxRuns")
    run_count: int = Field(alias="runCount")
    last_run_at: Optional[str] = Field(alias="lastRunAt")
    enabled: bool

recurrenceScheduleRecurrenceTypeRequired

repeat_everyOptional[int]Required

How many repeatUnits apart the runs are, or null when the alert runs once.

Example: 1

repeat_unitOptional[ScheduleIntervalUnit]Required

start_atOptional[str]Required

When the schedule first runs, or null when it started immediately.

end_atOptional[str]Required

When the schedule stops running, or null when it is open-ended.

max_runsOptional[int]Required

How many times the alert runs before it stops, or null when it runs indefinitely.

run_countintRequired

How many times the alert has run so far.

Example: 12

last_run_atOptional[str]Required

When the alert last ran, or null until its first run.

Example: "2025-02-01T10:00:00+00:00"

enabledboolRequired

Whether the schedule is currently running.

Example: true

ScheduledAlertSummary

An alert as it appears in a list: what it measures and whether it is running. Retrieve it by id for its aggregation, filters, threshold, severity and run history.

class ScheduledAlertSummary:
    id: str
    name: str
    data_model: AlertDataModel = Field(alias="dataModel")
    enabled: bool

idstrRequired

The id of the scheduled alert, generated by Confident AI.

Example: "<SCHEDULED-ALERT-ID>"

namestrRequired

The name of the alert.

Example: "Trace error rate spike"

data_modelAlertDataModelRequired

enabledboolRequired

Whether the alert's schedule is running. False when the alert has no schedule.

Example: true

Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI