Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(alerts): add configurable alert start times (#96698)

Matt Pua432b6f484d14
diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr
index ea14d5b5acef..049bb8850bc8 100644
--- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr
+++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr
@@ -2480,6 +2480,7 @@
"posthog_alertconfiguration"."snoozed_until",
"posthog_alertconfiguration"."skip_weekend",
"posthog_alertconfiguration"."schedule_restriction",
+ "posthog_alertconfiguration"."schedule_start_time",
"posthog_alertconfiguration"."investigation_agent_enabled",
"posthog_alertconfiguration"."investigation_gates_notifications",
"posthog_alertconfiguration"."investigation_inconclusive_action",
@@ -8144,6 +8145,7 @@
"posthog_alertconfiguration"."snoozed_until",
"posthog_alertconfiguration"."skip_weekend",
"posthog_alertconfiguration"."schedule_restriction",
+ "posthog_alertconfiguration"."schedule_start_time",
"posthog_alertconfiguration"."investigation_agent_enabled",
"posthog_alertconfiguration"."investigation_gates_notifications",
"posthog_alertconfiguration"."investigation_inconclusive_action",
diff --git a/posthog/api/test/test_alert_15_minute_interval.py b/posthog/api/test/test_alert_15_minute_interval.py
index 7639d1b9f5b2..3696372ddd5e 100644
--- a/posthog/api/test/test_alert_15_minute_interval.py
+++ b/posthog/api/test/test_alert_15_minute_interval.py
@@ -105,6 +105,7 @@ class TestAlert15MinuteScheduling:
alert.next_check_at = datetime(2026, 4, 6, 14, 0, 0, tzinfo=UTC)
alert.team = MagicMock()
alert.team.timezone = "UTC"
+ alert.schedule_start_time = None
alert.schedule_restriction = None
alert.skip_weekend = False
diff --git a/posthog/api/test/test_alert_real_time_interval.py b/posthog/api/test/test_alert_real_time_interval.py
index 5a2380ff4832..0a6ece20926e 100644
--- a/posthog/api/test/test_alert_real_time_interval.py
+++ b/posthog/api/test/test_alert_real_time_interval.py
@@ -176,6 +176,7 @@ class TestAlertRealTimeScheduling:
alert.next_check_at = datetime(2026, 4, 6, 14, 0, 0, tzinfo=UTC)
alert.team = MagicMock()
alert.team.timezone = "UTC"
+ alert.schedule_start_time = None
alert.schedule_restriction = None
alert.skip_weekend = False
diff --git a/posthog/models/activity_logging/activity_log.py b/posthog/models/activity_logging/activity_log.py
index 1aabb132ff00..85adfca32709 100644
--- a/posthog/models/activity_logging/activity_log.py
+++ b/posthog/models/activity_logging/activity_log.py
@@ -335,6 +335,9 @@ field_with_masked_contents: dict[AuditableScope, list[str]] = {
}
field_name_overrides: dict[AuditableScope, dict[str, str]] = {
+ "AlertConfiguration": {
+ "schedule_start_time": "schedule start time",
+ },
"HogFunction": {
"execution_order": "priority",
},
diff --git a/posthog/tasks/alerts/test/test_schedule_restriction.py b/posthog/tasks/alerts/test/test_schedule_restriction.py
index 8dca597c738b..0be61a89e6d4 100644
--- a/posthog/tasks/alerts/test/test_schedule_restriction.py
+++ b/posthog/tasks/alerts/test/test_schedule_restriction.py
@@ -68,6 +68,7 @@ class TestNextCheckAtAfterScheduleRestrictionChange:
alert.team = MagicMock()
alert.team.timezone = "UTC"
alert.calculation_interval = "hourly"
+ alert.schedule_start_time = None
for k, v in kwargs.items():
setattr(alert, k, v)
return alert
@@ -89,6 +90,16 @@ class TestNextCheckAtAfterScheduleRestrictionChange:
out = next_check_at_after_schedule_restriction_change(alert)
assert out == datetime(2026, 4, 6, 16, 0, 0, tzinfo=UTC)
+ def test_custom_schedule_start_time_inside_blocked_window_snaps_to_first_unblocked_minute(self) -> None:
+ with freeze_time("2026-04-06T20:00:00Z"):
+ alert = self._hourly_alert(
+ schedule_restriction={"blocked_windows": [{"start": "22:00", "end": "07:00"}]},
+ schedule_start_time="22:30",
+ next_check_at=None,
+ )
+ out = next_check_at_after_schedule_restriction_change(alert)
+ assert out == datetime(2026, 4, 7, 7, 0, tzinfo=UTC)
+
def test_does_not_keep_stale_snap_when_earlier_runs_are_allowed(self) -> None:
with freeze_time("2026-04-06T16:44:00Z"):
alert = self._hourly_alert(
diff --git a/posthog/tasks/alerts/test/test_utils.py b/posthog/tasks/alerts/test/test_utils.py
index 3e7ece2b6bc5..904d896fb49a 100644
--- a/posthog/tasks/alerts/test/test_utils.py
+++ b/posthog/tasks/alerts/test/test_utils.py
@@ -38,6 +38,7 @@ class TestAlertUtils:
alert.next_check_at = datetime(2026, 4, 6, 14, 0, 0, tzinfo=UTC)
alert.team = MagicMock()
alert.team.timezone = "UTC"
+ alert.schedule_start_time = None
alert.schedule_restriction = None
alert.skip_weekend = False
diff --git a/posthog/tasks/alerts/utils.py b/posthog/tasks/alerts/utils.py
index 7520d71ee634..fc396a1bae2e 100644
--- a/posthog/tasks/alerts/utils.py
+++ b/posthog/tasks/alerts/utils.py
@@ -122,6 +122,7 @@ def _next_check_time_core(alert: AlertConfiguration) -> datetime:
now=datetime.now(pytz.UTC),
tz_name=alert.team.timezone,
next_check_at=alert.next_check_at,
+ schedule_start_time=alert.schedule_start_time,
)
diff --git a/posthog/temporal/tests/test_alerts_activities.py b/posthog/temporal/tests/test_alerts_activities.py
index ce414d5a1307..d4d917dd6fe2 100644
--- a/posthog/temporal/tests/test_alerts_activities.py
+++ b/posthog/temporal/tests/test_alerts_activities.py
@@ -96,6 +96,7 @@ async def _create_alert(
snoozed_until: datetime | None = None,
skip_weekend: bool = False,
schedule_restriction: dict | None = None,
+ schedule_start_time: str | None = None,
insight_deleted: bool = False,
state: str = AlertState.NOT_FIRING,
) -> AlertConfiguration:
@@ -125,6 +126,7 @@ async def _create_alert(
snoozed_until=snoozed_until,
skip_weekend=skip_weekend,
schedule_restriction=schedule_restriction,
+ schedule_start_time=schedule_start_time,
state=state,
)
return alert
@@ -244,7 +246,7 @@ class TestPrepareAlert:
),
pytest.param(
"2024-12-21T08:00:00Z", # Saturday
- {"skip_weekend": True},
+ {"skip_weekend": True, "schedule_start_time": "08:30"},
SkipReason.WEEKEND,
True,
id="weekend",
diff --git a/posthog/test/activity_logging/test_alert_activity_logging.py b/posthog/test/activity_logging/test_alert_activity_logging.py
index b6fbe8c9103f..7404eb41315c 100644
--- a/posthog/test/activity_logging/test_alert_activity_logging.py
+++ b/posthog/test/activity_logging/test_alert_activity_logging.py
@@ -149,6 +149,27 @@ class TestAlertActivityLogging(ActivityLogTestHelper):
self.assertEqual(interval_change["before"], "daily")
self.assertEqual(interval_change["after"], "hourly")
+ def test_alert_schedule_start_time_change_is_logged(self):
+ alert = self.create_alert_configuration("Alert with schedule start time")
+
+ self.update_alert_configuration(alert["id"], {"schedule_start_time": "08:02"})
+
+ update_log = (
+ ActivityLog.objects.filter(
+ team_id=self.team.id, scope="AlertConfiguration", item_id=str(alert["id"]), activity="updated"
+ )
+ .order_by("-created_at")
+ .first()
+ )
+
+ assert update_log is not None
+ assert update_log.detail is not None
+ schedule_change = next(
+ (change for change in update_log.detail.get("changes", []) if change.get("field") == "schedule start time"),
+ None,
+ )
+ self.assertIsNotNone(schedule_change)
+
def test_alert_configuration_threshold_update_logging(self):
alert = self.create_alert_configuration(
name="Alert for threshold update",
diff --git a/products/alerts/backend/facade/api.py b/products/alerts/backend/facade/api.py
index 0b9b0e76d271..1824c2bab7cd 100644
--- a/products/alerts/backend/facade/api.py
+++ b/products/alerts/backend/facade/api.py
@@ -45,7 +45,10 @@ from products.alerts.backend.insight_alert_destinations import (
from products.alerts.backend.insight_alert_state_machine import apply_snooze
from products.alerts.backend.models.alert import AlertCheck, AlertConfiguration
from products.alerts.backend.presentation.views.alert_schedule_restriction import AlertScheduleRestriction
-from products.alerts.backend.scheduling import validate_and_normalize_schedule_restriction
+from products.alerts.backend.scheduling import (
+ validate_and_normalize_schedule_restriction,
+ validate_and_normalize_schedule_start_time,
+)
logger = structlog.get_logger(__name__)
@@ -243,4 +246,5 @@ __all__ = [
"send_alert_email",
"validate_destination_data",
"validate_and_normalize_schedule_restriction",
+ "validate_and_normalize_schedule_start_time",
]
diff --git a/products/alerts/backend/migrations/0005_alertconfiguration_schedule_start_time.py b/products/alerts/backend/migrations/0005_alertconfiguration_schedule_start_time.py
new file mode 100644
index 000000000000..3231f9fa0885
--- /dev/null
+++ b/products/alerts/backend/migrations/0005_alertconfiguration_schedule_start_time.py
@@ -0,0 +1,15 @@
+# Generated by Django 5.2.17
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [("alerts", "0004_squash_2026_09_07_finalize_fks")]
+
+ operations = [
+ migrations.AddField(
+ model_name="alertconfiguration",
+ name="schedule_start_time",
+ field=models.CharField(blank=True, default=None, max_length=5, null=True),
+ ),
+ ]
diff --git a/products/alerts/backend/migrations/max_migration.txt b/products/alerts/backend/migrations/max_migration.txt
index bde7efb4f341..865616773c2d 100644
--- a/products/alerts/backend/migrations/max_migration.txt
+++ b/products/alerts/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0004_squash_2026_09_07_finalize_fks
+0005_alertconfiguration_schedule_start_time
diff --git a/products/alerts/backend/models/alert.py b/products/alerts/backend/models/alert.py
index 9b5c36cf966f..d6206a1c35f9 100644
--- a/products/alerts/backend/models/alert.py
+++ b/products/alerts/backend/models/alert.py
@@ -162,6 +162,7 @@ class AlertConfiguration(ModelActivityMixin, CreatedMetaFields, UUIDTModel):
skip_weekend = models.BooleanField(null=True, blank=True, default=False)
schedule_restriction = models.JSONField(null=True, blank=True, default=None)
+ schedule_start_time = models.CharField(max_length=5, null=True, blank=True, default=None)
# When enabled, an investigation agent runs on each firing check, up to three per
# firing episode, and writes its findings to a linked Notebook. Only effective for
diff --git a/products/alerts/backend/presentation/views/alert.py b/products/alerts/backend/presentation/views/alert.py
index 7ff2f90cab5c..ec000459c3fc 100644
--- a/products/alerts/backend/presentation/views/alert.py
+++ b/products/alerts/backend/presentation/views/alert.py
@@ -78,6 +78,7 @@ from products.alerts.backend.facade.api import (
count_active_alert_destinations,
create_alert_destination_hog_functions,
soft_delete_alert_destinations,
+ validate_and_normalize_schedule_start_time,
validate_destination_data,
)
from products.alerts.backend.insight_alert_state_machine import (
@@ -458,6 +459,11 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
required=False,
help_text="How often the alert is checked: real time (Scale+), every 15 minutes (Boost+), hourly, daily, weekly, or monthly.",
)
+ schedule_start_time = serializers.CharField(
+ required=False,
+ allow_null=True,
+ help_text="Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior.",
+ )
snoozed_until = RelativeDateTimeField(
allow_null=True,
required=False,
@@ -520,6 +526,7 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
"enabled",
"last_notified_at",
"last_checked_at",
+ "schedule_start_time",
"next_check_at",
"checks",
"checks_total",
@@ -566,6 +573,7 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
)
return threshold_instance
+ @transaction.atomic
def create(self, validated_data: dict) -> AlertConfiguration:
validated_data["team_id"] = self.context["team_id"]
validated_data["created_by"] = self.context["request"].user
@@ -585,6 +593,9 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
validated_data["threshold"] = threshold_instance
instance: AlertConfiguration = super().create(validated_data)
+ if instance.schedule_start_time is not None:
+ instance.next_check_at = next_check_at_after_schedule_restriction_change(instance)
+ instance.save(update_fields=["next_check_at"])
for user in subscribed_users:
AlertSubscription.objects.create(
@@ -599,6 +610,7 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
@transaction.atomic
def update(self, instance, validated_data):
+ instance = AlertConfiguration.objects.select_for_update().get(pk=instance.pk)
enabled_changed = "enabled" in validated_data and validated_data["enabled"] != instance.enabled
resulting_enabled = validated_data.get("enabled", instance.enabled)
if enabled_changed and validated_data["enabled"]:
@@ -671,13 +683,16 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
)
schedule_restriction_changed = False
+ schedule_start_time_changed = False
if "schedule_restriction" in validated_data:
new_sr = validated_data["schedule_restriction"]
if new_sr != instance.schedule_restriction:
schedule_restriction_changed = True
+ if "schedule_start_time" in validated_data:
+ schedule_start_time_changed = validated_data["schedule_start_time"] != instance.schedule_start_time
instance = super().update(instance, validated_data)
- if schedule_restriction_changed:
+ if schedule_restriction_changed and not schedule_start_time_changed:
instance.next_check_at = next_check_at_after_schedule_restriction_change(instance)
instance.save(update_fields=["next_check_at"])
@@ -687,6 +702,12 @@ class AlertSerializer(SearchMatchTypeSerializerMixin, serializers.ModelSerialize
)
return instance
+ def validate_schedule_start_time(self, value: str | None) -> str | None:
+ try:
+ return validate_and_normalize_schedule_start_time(value)
+ except ValueError:
+ raise serializers.ValidationError("Invalid schedule start time.")
+
def validate_detector_config(self, value):
if value is None:
return value
diff --git a/products/alerts/backend/scheduling.py b/products/alerts/backend/scheduling.py
index cee8146943b5..4b59b0ad59e6 100644
--- a/products/alerts/backend/scheduling.py
+++ b/products/alerts/backend/scheduling.py
@@ -14,10 +14,12 @@ from __future__ import annotations
from collections.abc import Callable
from datetime import UTC, date, datetime, timedelta
from enum import StrEnum
+from math import ceil
from typing import Any, cast
from uuid import UUID
import pytz
+from dateutil.relativedelta import relativedelta
from pytz.exceptions import AmbiguousTimeError, NonExistentTimeError
from pytz.tzinfo import BaseTzInfo
@@ -146,12 +148,95 @@ def _calendar_anchor_utc(
return _localize_wall_time(team_timezone, naive_local).astimezone(UTC)
+def _next_check_at_for_schedule_start_time(
+ interval: CalendarInterval,
+ *,
+ now: datetime,
+ team_timezone: BaseTzInfo,
+ local_now: datetime,
+ next_check_at: datetime | None,
+ schedule_start_time: str,
+) -> datetime:
+ start_minutes = _parse_hhmm(schedule_start_time)
+ start_hour, start_minute = divmod(start_minutes, 60)
+ start_local = local_now.replace(hour=start_hour, minute=start_minute, second=0, microsecond=0)
+ start_utc = _localize_wall_time(team_timezone, start_local.replace(tzinfo=None)).astimezone(UTC)
+
+ match interval:
+ case CalendarInterval.REAL_TIME | CalendarInterval.EVERY_15_MINUTES | CalendarInterval.HOURLY:
+ cadence_minutes = {
+ CalendarInterval.REAL_TIME: REAL_TIME_CADENCE_MINUTES,
+ CalendarInterval.EVERY_15_MINUTES: EVERY_15_MINUTES_CADENCE_MINUTES,
+ CalendarInterval.HOURLY: 60,
+ }[interval]
+ earliest_allowed = next_check_at + timedelta(minutes=cadence_minutes) if next_check_at else now
+ earliest_allowed = max(earliest_allowed, now)
+ if next_check_at is not None or start_utc <= now:
+ elapsed_seconds = (earliest_allowed - start_utc).total_seconds()
+ intervals_to_advance = ceil(elapsed_seconds / (cadence_minutes * 60))
+ start_utc += timedelta(minutes=intervals_to_advance * cadence_minutes)
+ if start_utc <= now:
+ start_utc += timedelta(minutes=cadence_minutes)
+ return start_utc
+ case CalendarInterval.DAILY:
+ return _next_calendar_schedule_start_time(
+ start_local,
+ now=now,
+ team_timezone=team_timezone,
+ next_check_at=next_check_at,
+ interval_delta=timedelta(days=1),
+ )
+ case CalendarInterval.WEEKLY:
+ return _next_calendar_schedule_start_time(
+ start_local + timedelta(days=(7 - start_local.weekday()) % 7),
+ now=now,
+ team_timezone=team_timezone,
+ next_check_at=next_check_at,
+ interval_delta=timedelta(days=7),
+ )
+ case CalendarInterval.MONTHLY:
+ return _next_calendar_schedule_start_time(
+ start_local.replace(day=1),
+ now=now,
+ team_timezone=team_timezone,
+ next_check_at=next_check_at,
+ interval_delta=relativedelta(months=1),
+ )
+
+
+def _next_calendar_schedule_start_time(
+ first_candidate_local: datetime,
+ *,
+ now: datetime,
+ team_timezone: BaseTzInfo,
+ next_check_at: datetime | None,
+ interval_delta: timedelta | relativedelta,
+) -> datetime:
+ earliest_allowed = now
+ if next_check_at is not None:
+ earliest_allowed = max(
+ earliest_allowed,
+ _localize_wall_time(
+ team_timezone,
+ (next_check_at.astimezone(team_timezone) + interval_delta).replace(tzinfo=None),
+ ).astimezone(UTC),
+ )
+
+ candidate_local = first_candidate_local
+ candidate_utc = _localize_wall_time(team_timezone, candidate_local.replace(tzinfo=None)).astimezone(UTC)
+ while candidate_utc <= now or candidate_utc < earliest_allowed:
+ candidate_local += interval_delta
+ candidate_utc = _localize_wall_time(team_timezone, candidate_local.replace(tzinfo=None)).astimezone(UTC)
+ return candidate_utc
+
+
def next_calendar_check_time(
interval: CalendarInterval,
*,
now: datetime,
tz_name: str,
next_check_at: datetime | None,
+ schedule_start_time: str | None = None,
) -> datetime:
"""Nominal next check instant, before quiet-hours snapping.
@@ -164,6 +249,16 @@ def next_calendar_check_time(
team_timezone = pytz.timezone(tz_name)
local_now = now.astimezone(team_timezone)
+ if schedule_start_time is not None:
+ return _next_check_at_for_schedule_start_time(
+ interval,
+ now=now,
+ team_timezone=team_timezone,
+ local_now=local_now,
+ next_check_at=next_check_at,
+ schedule_start_time=schedule_start_time,
+ )
+
match interval:
case CalendarInterval.REAL_TIME | CalendarInterval.EVERY_15_MINUTES | CalendarInterval.HOURLY:
interval_delta = {
@@ -255,6 +350,14 @@ def _parse_hhmm(value: str) -> int:
return h * 60 + m
+def validate_and_normalize_schedule_start_time(raw: Any) -> str | None:
+ if raw is None:
+ return None
+ if not isinstance(raw, str):
+ raise ValueError("schedule_start_time must be a HH:MM string")
+ return _hhmm(_parse_hhmm(raw))
+
+
def _parse_window_pair(start_s: str, end_s: str) -> BlockedWindow:
start = _parse_hhmm(start_s)
end = _parse_hhmm(end_s)
diff --git a/products/alerts/backend/test/test_scheduling.py b/products/alerts/backend/test/test_scheduling.py
index de608d419c68..0dac7510f588 100644
--- a/products/alerts/backend/test/test_scheduling.py
+++ b/products/alerts/backend/test/test_scheduling.py
@@ -13,6 +13,7 @@ from products.alerts.backend.scheduling import (
parse_blocked_windows_tuples,
scan_next_unblocked_utc,
validate_and_normalize_schedule_restriction,
+ validate_and_normalize_schedule_start_time,
)
# Wednesday 2026-03-18 12:00 UTC
@@ -123,6 +124,109 @@ class TestValidateAndNormalizeScheduleRestriction:
validate_and_normalize_schedule_restriction(raw)
+class TestScheduleStartTime:
+ def test_accepts_any_valid_minute(self) -> None:
+ assert validate_and_normalize_schedule_start_time("08:02") == "08:02"
+
+ def test_hourly_check_returns_to_the_custom_minute_after_a_quiet_hours_delay(self) -> None:
+ assert next_calendar_check_time(
+ CalendarInterval.HOURLY,
+ now=datetime(2026, 4, 7, 7, 0, tzinfo=UTC),
+ tz_name="UTC",
+ next_check_at=datetime(2026, 4, 7, 7, 0, tzinfo=UTC),
+ schedule_start_time="22:30",
+ ) == datetime(2026, 4, 7, 8, 30, tzinfo=UTC)
+
+ def test_hourly_alert_created_after_its_start_time_uses_the_first_future_check(self) -> None:
+ assert next_calendar_check_time(
+ CalendarInterval.HOURLY,
+ now=datetime(2026, 4, 6, 23, 50, tzinfo=UTC),
+ tz_name="UTC",
+ next_check_at=None,
+ schedule_start_time="09:35",
+ ) == datetime(2026, 4, 7, 0, 35, tzinfo=UTC)
+
+ @parameterized.expand(
+ [
+ (CalendarInterval.REAL_TIME, datetime(2026, 3, 18, 9, 35, tzinfo=UTC)),
+ (CalendarInterval.EVERY_15_MINUTES, datetime(2026, 3, 18, 9, 35, tzinfo=UTC)),
+ (CalendarInterval.HOURLY, datetime(2026, 3, 18, 9, 35, tzinfo=UTC)),
+ (CalendarInterval.DAILY, datetime(2026, 3, 18, 9, 35, tzinfo=UTC)),
+ (CalendarInterval.WEEKLY, datetime(2026, 3, 23, 9, 35, tzinfo=UTC)),
+ (CalendarInterval.MONTHLY, datetime(2026, 4, 1, 9, 35, tzinfo=UTC)),
+ ]
+ )
+ def test_next_check_uses_schedule_start_time_on_create(
+ self, interval: CalendarInterval, expected: datetime
+ ) -> None:
+ assert (
+ next_calendar_check_time(
+ interval,
+ now=datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ tz_name="UTC",
+ next_check_at=None,
+ schedule_start_time="09:35",
+ )
+ == expected
+ )
+
+ @parameterized.expand(
+ [
+ (
+ CalendarInterval.REAL_TIME,
+ datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ datetime(2026, 3, 18, 9, 33, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.HOURLY,
+ datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ datetime(2026, 3, 18, 10, 35, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.HOURLY,
+ datetime(2026, 3, 18, 9, 30, 1, tzinfo=UTC),
+ datetime(2026, 3, 18, 10, 35, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.EVERY_15_MINUTES,
+ datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ datetime(2026, 3, 18, 9, 50, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.EVERY_15_MINUTES,
+ datetime(2026, 3, 18, 9, 30, 1, tzinfo=UTC),
+ datetime(2026, 3, 18, 9, 50, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.DAILY,
+ datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ datetime(2026, 3, 19, 9, 35, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.WEEKLY,
+ datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ datetime(2026, 3, 30, 9, 35, tzinfo=UTC),
+ ),
+ (
+ CalendarInterval.MONTHLY,
+ datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ datetime(2026, 5, 1, 9, 35, tzinfo=UTC),
+ ),
+ ]
+ )
+ def test_next_check_respects_the_cadence_after_an_anchor_edit(
+ self, interval: CalendarInterval, now: datetime, expected: datetime
+ ) -> None:
+ result = next_calendar_check_time(
+ interval,
+ now=now,
+ tz_name="UTC",
+ next_check_at=datetime(2026, 3, 18, 9, 30, tzinfo=UTC),
+ schedule_start_time="09:35",
+ )
+ assert result == expected
+
+
class TestNextCalendarCheckTime:
@parameterized.expand(
[
diff --git a/products/alerts/backend/tests/api/test_alert.py b/products/alerts/backend/tests/api/test_alert.py
index 64f55a216dd4..0757fd413f7c 100644
--- a/products/alerts/backend/tests/api/test_alert.py
+++ b/products/alerts/backend/tests/api/test_alert.py
@@ -96,6 +96,7 @@ class TestAlert(APIBaseTest, QueryMatchingTest):
"snoozed_until": None,
"skip_weekend": False,
"schedule_restriction": None,
+ "schedule_start_time": None,
"last_value": None,
"investigation_agent_enabled": False,
"investigation_gates_notifications": False,
@@ -1188,6 +1189,123 @@ class TestAlert(APIBaseTest, QueryMatchingTest):
persisted_alert = AlertConfiguration.objects.get(id=alert["id"])
assert persisted_alert.next_check_at == (None if clears_next_check else scheduled_check)
+ @parameterized.expand(
+ [
+ ("real_time", "real_time", "2026-03-18T09:35:00+00:00"),
+ ("every_15_minutes", "every_15_minutes", "2026-03-18T09:35:00+00:00"),
+ ("hourly", "hourly", "2026-03-18T09:35:00+00:00"),
+ ("daily", "daily", "2026-03-18T09:35:00+00:00"),
+ ("weekly", "weekly", "2026-03-23T09:35:00+00:00"),
+ ("monthly", "monthly", "2026-04-01T09:35:00+00:00"),
+ ]
+ )
+ @freeze_time("2026-03-18T09:30:00Z")
+ def test_create_alert_with_schedule_start_time(
+ self, _name: str, calculation_interval: str, expected_next_check_at: str
+ ) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.HIGH_FREQUENCY_ALERTS, "name": "High-frequency alerts"},
+ {"key": AvailableFeature.REAL_TIME_ALERTS, "name": "Real-time alerts"},
+ ]
+ self.organization.save()
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/alerts",
+ {
+ "insight": self.insight["id"],
+ "subscribed_users": [self.user.id],
+ "condition": {"type": AlertConditionType.ABSOLUTE_VALUE},
+ "config": {"type": "TrendsAlertConfig", "series_index": 0},
+ "name": "scheduled alert",
+ "threshold": {"configuration": {"type": InsightThresholdType.ABSOLUTE, "bounds": {"upper": 100}}},
+ "calculation_interval": calculation_interval,
+ "schedule_start_time": "09:35",
+ },
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.content
+ assert response.json()["schedule_start_time"] == "09:35"
+ assert datetime.fromisoformat(
+ response.json()["next_check_at"].replace("Z", "+00:00")
+ ) == datetime.fromisoformat(expected_next_check_at)
+
+ @parameterized.expand(
+ [
+ ("real_time", "real_time"),
+ ("every_15_minutes", "every_15_minutes"),
+ ("hourly", "hourly"),
+ ("daily", "daily"),
+ ("weekly", "weekly"),
+ ("monthly", "monthly"),
+ ]
+ )
+ @freeze_time("2026-03-18T09:00:00Z")
+ def test_patch_schedule_start_time_keeps_the_current_next_check(
+ self, _name: str, calculation_interval: str
+ ) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.HIGH_FREQUENCY_ALERTS, "name": "High-frequency alerts"},
+ {"key": AvailableFeature.REAL_TIME_ALERTS, "name": "Real-time alerts"},
+ ]
+ self.organization.save()
+ alert = self.client.post(
+ f"/api/projects/{self.team.id}/alerts",
+ {
+ "insight": self.insight["id"],
+ "subscribed_users": [self.user.id],
+ "condition": {"type": AlertConditionType.ABSOLUTE_VALUE},
+ "config": {"type": "TrendsAlertConfig", "series_index": 0},
+ "name": "scheduled alert",
+ "threshold": {"configuration": {"type": InsightThresholdType.ABSOLUTE, "bounds": {"upper": 100}}},
+ "calculation_interval": calculation_interval,
+ "schedule_start_time": "09:30",
+ },
+ format="json",
+ ).json()
+ scheduled_check = datetime(2026, 3, 18, 9, 30, tzinfo=UTC)
+ AlertConfiguration.objects.filter(id=alert["id"]).update(next_check_at=scheduled_check)
+
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/alerts/{alert['id']}",
+ {"schedule_start_time": "08:35"},
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_200_OK, response.content
+ assert response.json()["schedule_start_time"] == "08:35"
+ assert datetime.fromisoformat(response.json()["next_check_at"].replace("Z", "+00:00")) == scheduled_check
+
+ @freeze_time("2026-03-18T09:00:00Z")
+ def test_patch_schedule_start_time_with_schedule_restriction_keeps_the_current_next_check(self) -> None:
+ alert = self.client.post(
+ f"/api/projects/{self.team.id}/alerts",
+ {
+ "insight": self.insight["id"],
+ "subscribed_users": [self.user.id],
+ "condition": {"type": AlertConditionType.ABSOLUTE_VALUE},
+ "config": {"type": "TrendsAlertConfig", "series_index": 0},
+ "name": "scheduled alert",
+ "threshold": {"configuration": {"type": InsightThresholdType.ABSOLUTE, "bounds": {"upper": 100}}},
+ "calculation_interval": "hourly",
+ "schedule_start_time": "09:30",
+ },
+ format="json",
+ ).json()
+ scheduled_check = datetime(2026, 3, 18, 10, 30, tzinfo=UTC)
+ AlertConfiguration.objects.filter(id=alert["id"]).update(next_check_at=scheduled_check)
+
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/alerts/{alert['id']}",
+ {
+ "schedule_start_time": "09:35",
+ "schedule_restriction": {"blocked_windows": [{"start": "22:00", "end": "07:00"}]},
+ },
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_200_OK, response.content
+ assert datetime.fromisoformat(response.json()["next_check_at"].replace("Z", "+00:00")) == scheduled_check
+
def test_create_alert_with_schedule_restriction(self) -> None:
creation_request = {
"insight": self.insight["id"],
diff --git a/products/alerts/frontend/generated/api.schemas.ts b/products/alerts/frontend/generated/api.schemas.ts
index f598ed89842d..87f632207a7c 100644
--- a/products/alerts/frontend/generated/api.schemas.ts
+++ b/products/alerts/frontend/generated/api.schemas.ts
@@ -657,6 +657,11 @@ export interface AlertApi {
readonly last_notified_at: string | null
/** @nullable */
readonly last_checked_at: string | null
+ /**
+ * Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior.
+ * @nullable
+ */
+ schedule_start_time?: string | null
/** @nullable */
readonly next_check_at: string | null
/** Alert check results. By default returns the last 5. Use checks_date_from and checks_date_to (e.g. '-24h', '-7d') to get checks within a time window, checks_limit to cap how many are returned (default 5, max 500), and checks_offset to skip the newest N checks for pagination (0-based). Newest checks first. Only populated on retrieve. */
@@ -746,6 +751,11 @@ export interface PatchedAlertApi {
readonly last_notified_at?: string | null
/** @nullable */
readonly last_checked_at?: string | null
+ /**
+ * Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior.
+ * @nullable
+ */
+ schedule_start_time?: string | null
/** @nullable */
readonly next_check_at?: string | null
/** Alert check results. By default returns the last 5. Use checks_date_from and checks_date_to (e.g. '-24h', '-7d') to get checks within a time window, checks_limit to cap how many are returned (default 5, max 500), and checks_offset to skip the newest N checks for pagination (0-based). Newest checks first. Only populated on retrieve. */
diff --git a/products/alerts/mcp/tools.yaml b/products/alerts/mcp/tools.yaml
index 803d93486fcc..57e9e1564137 100644
--- a/products/alerts/mcp/tools.yaml
+++ b/products/alerts/mcp/tools.yaml
@@ -49,6 +49,9 @@ tools:
add-on. The field is optional and defaults to daily. If the user does not specify a cadence, ask before
creating the alert.
+ To set the check time, pass schedule_start_time with a local HH:MM time. Updates take effect after the
+ current next_check_at, so they cannot increase the alert check frequency.
+
Note: subscribed_users only controls email recipients. To also post the alert to Slack, create it and then
call alert-destinations-create with the workspace and channel. For HTTPS webhook or Discord delivery, see
the recipe on cdp-functions-create — it covers integration lookup (integrations-channels-retrieve), dedupe
@@ -168,8 +171,9 @@ tools:
to anomaly detection (trends and SQL insights), or set it to null to switch back to threshold mode
(threshold mode requires at least one of lower or upper in threshold.configuration.bounds). For SQL-insight
alerts the config is HogQLAlertConfig (column, evaluation 'last_row'/'first_row'/'any_row', label_column).
- To snooze an alert, set snoozed_until to a relative date string (e.g. '2h', '1d'). To unsnooze, set
- snoozed_until to null.
+ Pass schedule_start_time with a local HH:MM time to change later checks. The current next_check_at stays
+ unchanged, so an update cannot increase the alert check frequency. To snooze an alert, set snoozed_until to
+ a relative date string (e.g. '2h', '1d'). To unsnooze, set snoozed_until to null.
Note: Slack/webhook/Discord delivery for this alert lives as a HogFunction. Add or remove a Slack channel
with alert-destinations-create and alert-destinations-delete. For webhook and Discord, see the recipe on
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 7f86d2ad8e72..d053cc63827d 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -550,7 +550,7 @@
"feature_entitlement": "audit_logs"
},
"alert-create": {
- "description": "Create a new alert on an insight. Alerts can use either threshold-based conditions or anomaly detection. For threshold alerts: set condition (absolute_value, relative_increase, relative_decrease) and threshold configuration with bounds — at least one of lower or upper is required (omit detector_config). For anomaly detection: set detector_config with a detector type (zscore, mad, iqr, threshold, copod, ecod, hbos, isolation_forest, knn, lof, ocsvm, pca) and parameters like threshold (sensitivity 0-1, default 0.9) and window size. Ensemble detectors combine 2+ sub-detectors with AND/OR logic. Requires an insight ID and at least one subscribed user.\nThe config type must match the insight kind. Trends insights: TrendsAlertConfig (series_index, check_ongoing_interval). SQL/HogQL insights: HogQLAlertConfig — column picks which result column to evaluate (defaults to the single numeric column), evaluation is required and selects how rows are read: 'last_row' (query ordered oldest->newest, the last row is the current value), 'first_row' (query ordered newest->oldest, the first row is the current value — pair with a LIMIT, and it is unaffected by result truncation), or 'any_row' (every row is checked and the alert fires if any value breaches; absolute_value condition only). label_column names the evaluated row(s) in breach messages in every evaluation mode (defaults to the first non-evaluated column). Label values appear in delivered notifications — avoid label columns containing PII. Funnel insights: FunnelsAlertConfig — funnel_step picks the step to monitor (null for the overall last step), metric is 'conversion_from_start' or 'conversion_from_previous', and check_ongoing_interval (historical-trend funnels: also evaluate the current in-progress period). Steps funnels support only absolute_value conditions; historical-trend funnels also support relative_increase/relative_decrease. Anomaly detection (detector_config) is supported for trends and SQL insights (not funnels).\ncalculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. The field is optional and defaults to daily. If the user does not specify a cadence, ask before creating the alert.\nNote: subscribed_users only controls email recipients. To also post the alert to Slack, create it and then call alert-destinations-create with the workspace and channel. For HTTPS webhook or Discord delivery, see the recipe on cdp-functions-create — it covers integration lookup (integrations-channels-retrieve), dedupe (cdp-functions-list filtered by alert id, limit=1000), and the exact filters/inputs shape to pass.",
+ "description": "Create a new alert on an insight. Alerts can use either threshold-based conditions or anomaly detection. For threshold alerts: set condition (absolute_value, relative_increase, relative_decrease) and threshold configuration with bounds — at least one of lower or upper is required (omit detector_config). For anomaly detection: set detector_config with a detector type (zscore, mad, iqr, threshold, copod, ecod, hbos, isolation_forest, knn, lof, ocsvm, pca) and parameters like threshold (sensitivity 0-1, default 0.9) and window size. Ensemble detectors combine 2+ sub-detectors with AND/OR logic. Requires an insight ID and at least one subscribed user.\nThe config type must match the insight kind. Trends insights: TrendsAlertConfig (series_index, check_ongoing_interval). SQL/HogQL insights: HogQLAlertConfig — column picks which result column to evaluate (defaults to the single numeric column), evaluation is required and selects how rows are read: 'last_row' (query ordered oldest->newest, the last row is the current value), 'first_row' (query ordered newest->oldest, the first row is the current value — pair with a LIMIT, and it is unaffected by result truncation), or 'any_row' (every row is checked and the alert fires if any value breaches; absolute_value condition only). label_column names the evaluated row(s) in breach messages in every evaluation mode (defaults to the first non-evaluated column). Label values appear in delivered notifications — avoid label columns containing PII. Funnel insights: FunnelsAlertConfig — funnel_step picks the step to monitor (null for the overall last step), metric is 'conversion_from_start' or 'conversion_from_previous', and check_ongoing_interval (historical-trend funnels: also evaluate the current in-progress period). Steps funnels support only absolute_value conditions; historical-trend funnels also support relative_increase/relative_decrease. Anomaly detection (detector_config) is supported for trends and SQL insights (not funnels).\ncalculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. The field is optional and defaults to daily. If the user does not specify a cadence, ask before creating the alert.\nTo set the check time, pass schedule_start_time with a local HH:MM time. Updates take effect after the current next_check_at, so they cannot increase the alert check frequency.\nNote: subscribed_users only controls email recipients. To also post the alert to Slack, create it and then call alert-destinations-create with the workspace and channel. For HTTPS webhook or Discord delivery, see the recipe on cdp-functions-create — it covers integration lookup (integrations-channels-retrieve), dedupe (cdp-functions-list filtered by alert id, limit=1000), and the exact filters/inputs shape to pass.",
"category": "Alerts",
"feature": "alerts",
"summary": "Create alert",
@@ -634,7 +634,7 @@
}
},
"alert-update": {
- "description": "Update an existing alert by ID. Can update name, threshold, condition, config, detector_config, subscribed users, enabled state, calculation_interval, and weekend skipping. calculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. Set detector_config to switch to anomaly detection (trends and SQL insights), or set it to null to switch back to threshold mode (threshold mode requires at least one of lower or upper in threshold.configuration.bounds). For SQL-insight alerts the config is HogQLAlertConfig (column, evaluation 'last_row'/'first_row'/'any_row', label_column). To snooze an alert, set snoozed_until to a relative date string (e.g. '2h', '1d'). To unsnooze, set snoozed_until to null.\nNote: Slack/webhook/Discord delivery for this alert lives as a HogFunction. Add or remove a Slack channel with alert-destinations-create and alert-destinations-delete. For webhook and Discord, see the recipe on cdp-functions-create; to change or remove one of those, find it via cdp-functions-list (type=internal_destination, limit=1000) by matching filters.properties value against this alert's id, then use cdp-functions-partial-update or cdp-functions-delete.",
+ "description": "Update an existing alert by ID. Can update name, threshold, condition, config, detector_config, subscribed users, enabled state, calculation_interval, and weekend skipping. calculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. Set detector_config to switch to anomaly detection (trends and SQL insights), or set it to null to switch back to threshold mode (threshold mode requires at least one of lower or upper in threshold.configuration.bounds). For SQL-insight alerts the config is HogQLAlertConfig (column, evaluation 'last_row'/'first_row'/'any_row', label_column). Pass schedule_start_time with a local HH:MM time to change later checks. The current next_check_at stays unchanged, so an update cannot increase the alert check frequency. To snooze an alert, set snoozed_until to a relative date string (e.g. '2h', '1d'). To unsnooze, set snoozed_until to null.\nNote: Slack/webhook/Discord delivery for this alert lives as a HogFunction. Add or remove a Slack channel with alert-destinations-create and alert-destinations-delete. For webhook and Discord, see the recipe on cdp-functions-create; to change or remove one of those, find it via cdp-functions-list (type=internal_destination, limit=1000) by matching filters.properties value against this alert's id, then use cdp-functions-partial-update or cdp-functions-delete.",
"category": "Alerts",
"feature": "alerts",
"summary": "Update alert",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 034755ad6765..2f07cf6e6dd1 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -565,7 +565,7 @@
}
},
"alert-create": {
- "description": "Create a new alert on an insight. Alerts can use either threshold-based conditions or anomaly detection. For threshold alerts: set condition (absolute_value, relative_increase, relative_decrease) and threshold configuration with bounds — at least one of lower or upper is required (omit detector_config). For anomaly detection: set detector_config with a detector type (zscore, mad, iqr, threshold, copod, ecod, hbos, isolation_forest, knn, lof, ocsvm, pca) and parameters like threshold (sensitivity 0-1, default 0.9) and window size. Ensemble detectors combine 2+ sub-detectors with AND/OR logic. Requires an insight ID and at least one subscribed user.\nThe config type must match the insight kind. Trends insights: TrendsAlertConfig (series_index, check_ongoing_interval). SQL/HogQL insights: HogQLAlertConfig — column picks which result column to evaluate (defaults to the single numeric column), evaluation is required and selects how rows are read: 'last_row' (query ordered oldest->newest, the last row is the current value), 'first_row' (query ordered newest->oldest, the first row is the current value — pair with a LIMIT, and it is unaffected by result truncation), or 'any_row' (every row is checked and the alert fires if any value breaches; absolute_value condition only). label_column names the evaluated row(s) in breach messages in every evaluation mode (defaults to the first non-evaluated column). Label values appear in delivered notifications — avoid label columns containing PII. Funnel insights: FunnelsAlertConfig — funnel_step picks the step to monitor (null for the overall last step), metric is 'conversion_from_start' or 'conversion_from_previous', and check_ongoing_interval (historical-trend funnels: also evaluate the current in-progress period). Steps funnels support only absolute_value conditions; historical-trend funnels also support relative_increase/relative_decrease. Anomaly detection (detector_config) is supported for trends and SQL insights (not funnels).\ncalculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. The field is optional and defaults to daily. If the user does not specify a cadence, ask before creating the alert.\nNote: subscribed_users only controls email recipients. To also post the alert to Slack, create it and then call alert-destinations-create with the workspace and channel. For HTTPS webhook or Discord delivery, see the recipe on cdp-functions-create — it covers integration lookup (integrations-channels-retrieve), dedupe (cdp-functions-list filtered by alert id, limit=1000), and the exact filters/inputs shape to pass.",
+ "description": "Create a new alert on an insight. Alerts can use either threshold-based conditions or anomaly detection. For threshold alerts: set condition (absolute_value, relative_increase, relative_decrease) and threshold configuration with bounds — at least one of lower or upper is required (omit detector_config). For anomaly detection: set detector_config with a detector type (zscore, mad, iqr, threshold, copod, ecod, hbos, isolation_forest, knn, lof, ocsvm, pca) and parameters like threshold (sensitivity 0-1, default 0.9) and window size. Ensemble detectors combine 2+ sub-detectors with AND/OR logic. Requires an insight ID and at least one subscribed user.\nThe config type must match the insight kind. Trends insights: TrendsAlertConfig (series_index, check_ongoing_interval). SQL/HogQL insights: HogQLAlertConfig — column picks which result column to evaluate (defaults to the single numeric column), evaluation is required and selects how rows are read: 'last_row' (query ordered oldest->newest, the last row is the current value), 'first_row' (query ordered newest->oldest, the first row is the current value — pair with a LIMIT, and it is unaffected by result truncation), or 'any_row' (every row is checked and the alert fires if any value breaches; absolute_value condition only). label_column names the evaluated row(s) in breach messages in every evaluation mode (defaults to the first non-evaluated column). Label values appear in delivered notifications — avoid label columns containing PII. Funnel insights: FunnelsAlertConfig — funnel_step picks the step to monitor (null for the overall last step), metric is 'conversion_from_start' or 'conversion_from_previous', and check_ongoing_interval (historical-trend funnels: also evaluate the current in-progress period). Steps funnels support only absolute_value conditions; historical-trend funnels also support relative_increase/relative_decrease. Anomaly detection (detector_config) is supported for trends and SQL insights (not funnels).\ncalculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. The field is optional and defaults to daily. If the user does not specify a cadence, ask before creating the alert.\nTo set the check time, pass schedule_start_time with a local HH:MM time. Updates take effect after the current next_check_at, so they cannot increase the alert check frequency.\nNote: subscribed_users only controls email recipients. To also post the alert to Slack, create it and then call alert-destinations-create with the workspace and channel. For HTTPS webhook or Discord delivery, see the recipe on cdp-functions-create — it covers integration lookup (integrations-channels-retrieve), dedupe (cdp-functions-list filtered by alert id, limit=1000), and the exact filters/inputs shape to pass.",
"category": "Alerts",
"feature": "alerts",
"summary": "Create alert",
@@ -649,7 +649,7 @@
}
},
"alert-update": {
- "description": "Update an existing alert by ID. Can update name, threshold, condition, config, detector_config, subscribed users, enabled state, calculation_interval, and weekend skipping. calculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. Set detector_config to switch to anomaly detection (trends and SQL insights), or set it to null to switch back to threshold mode (threshold mode requires at least one of lower or upper in threshold.configuration.bounds). For SQL-insight alerts the config is HogQLAlertConfig (column, evaluation 'last_row'/'first_row'/'any_row', label_column). To snooze an alert, set snoozed_until to a relative date string (e.g. '2h', '1d'). To unsnooze, set snoozed_until to null.\nNote: Slack/webhook/Discord delivery for this alert lives as a HogFunction. Add or remove a Slack channel with alert-destinations-create and alert-destinations-delete. For webhook and Discord, see the recipe on cdp-functions-create; to change or remove one of those, find it via cdp-functions-list (type=internal_destination, limit=1000) by matching filters.properties value against this alert's id, then use cdp-functions-partial-update or cdp-functions-delete.",
+ "description": "Update an existing alert by ID. Can update name, threshold, condition, config, detector_config, subscribed users, enabled state, calculation_interval, and weekend skipping. calculation_interval sets how often the alert runs: real_time, every_15_minutes, hourly, daily, weekly, or monthly. real_time needs a Scale or Enterprise plan. every_15_minutes needs a Boost, Scale, or Enterprise add-on. Set detector_config to switch to anomaly detection (trends and SQL insights), or set it to null to switch back to threshold mode (threshold mode requires at least one of lower or upper in threshold.configuration.bounds). For SQL-insight alerts the config is HogQLAlertConfig (column, evaluation 'last_row'/'first_row'/'any_row', label_column). Pass schedule_start_time with a local HH:MM time to change later checks. The current next_check_at stays unchanged, so an update cannot increase the alert check frequency. To snooze an alert, set snoozed_until to a relative date string (e.g. '2h', '1d'). To unsnooze, set snoozed_until to null.\nNote: Slack/webhook/Discord delivery for this alert lives as a HogFunction. Add or remove a Slack channel with alert-destinations-create and alert-destinations-delete. For webhook and Discord, see the recipe on cdp-functions-create; to change or remove one of those, find it via cdp-functions-list (type=internal_destination, limit=1000) by matching filters.properties value against this alert's id, then use cdp-functions-partial-update or cdp-functions-delete.",
"category": "Alerts",
"feature": "alerts",
"summary": "Update alert",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index a2fce34e46f7..60dcaef6fb32 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -10254,6 +10254,11 @@ export namespace Schemas {
readonly last_notified_at: string | null;
/** @nullable */
readonly last_checked_at: string | null;
+ /**
+ * Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior.
+ * @nullable
+ */
+ schedule_start_time?: string | null;
/** @nullable */
readonly next_check_at: string | null;
/** Alert check results. By default returns the last 5. Use checks_date_from and checks_date_to (e.g. '-24h', '-7d') to get checks within a time window, checks_limit to cap how many are returned (default 5, max 500), and checks_offset to skip the newest N checks for pagination (0-based). Newest checks first. Only populated on retrieve. */
@@ -62244,6 +62249,11 @@ export namespace Schemas {
readonly last_notified_at?: string | null;
/** @nullable */
readonly last_checked_at?: string | null;
+ /**
+ * Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior.
+ * @nullable
+ */
+ schedule_start_time?: string | null;
/** @nullable */
readonly next_check_at?: string | null;
/** Alert check results. By default returns the last 5. Use checks_date_from and checks_date_to (e.g. '-24h', '-7d') to get checks within a time window, checks_limit to cap how many are returned (default 5, max 500), and checks_offset to skip the newest N checks for pagination (0-based). Newest checks first. Only populated on retrieve. */
diff --git a/services/mcp/src/generated/alerts/api.ts b/services/mcp/src/generated/alerts/api.ts
index d36d5b1b4640..f76aabc345e8 100644
--- a/services/mcp/src/generated/alerts/api.ts
+++ b/services/mcp/src/generated/alerts/api.ts
@@ -136,6 +136,12 @@ export const AlertsCreateBody = () => zod.object({
'Alert condition type. Determines how the value is evaluated: absolute_value, relative_increase, or relative_decrease.'
),
enabled: zod.boolean().optional().describe('Whether the alert is actively being evaluated.'),
+ schedule_start_time: zod
+ .string()
+ .nullish()
+ .describe(
+ "Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior."
+ ),
config: zod
.union([
zod
@@ -1443,6 +1449,12 @@ export const AlertsPartialUpdateBody = () => zod.object({
'Alert condition type. Determines how the value is evaluated: absolute_value, relative_increase, or relative_decrease.'
),
enabled: zod.boolean().optional().describe('Whether the alert is actively being evaluated.'),
+ schedule_start_time: zod
+ .string()
+ .nullish()
+ .describe(
+ "Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior."
+ ),
config: zod
.union([
zod
diff --git a/services/mcp/src/tools/generated/alerts.ts b/services/mcp/src/tools/generated/alerts.ts
index e213696bfc26..047bad623180 100644
--- a/services/mcp/src/tools/generated/alerts.ts
+++ b/services/mcp/src/tools/generated/alerts.ts
@@ -35,6 +35,9 @@ const alertCreate = (): ToolBase<ReturnType<typeof AlertCreateSchema>, WithPostH
if (params.enabled !== undefined) {
body['enabled'] = params.enabled
}
+ if (params.schedule_start_time !== undefined) {
+ body['schedule_start_time'] = params.schedule_start_time
+ }
if (params.config !== undefined) {
body['config'] = params.config
}
@@ -257,6 +260,9 @@ const alertUpdate = (): ToolBase<ReturnType<typeof AlertUpdateSchema>, WithPostH
if (params.enabled !== undefined) {
body['enabled'] = params.enabled
}
+ if (params.schedule_start_time !== undefined) {
+ body['schedule_start_time'] = params.schedule_start_time
+ }
if (params.config !== undefined) {
body['config'] = params.config
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-create.json
index 55200701f710..be15e9188bdf 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-create.json
@@ -2281,6 +2281,17 @@
],
"description": "Blocked local time windows (HH:MM in the project timezone). Interval is half-open [start, end): start inclusive, end exclusive. Use blocked_windows array of {start, end}. Null disables."
},
+ "schedule_start_time": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior."
+ },
"skip_weekend": {
"anyOf": [
{
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-update.json
index f1a9435eb606..5d3b3560609a 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/alert-update.json
@@ -2285,6 +2285,17 @@
],
"description": "Blocked local time windows (HH:MM in the project timezone). Interval is half-open [start, end): start inclusive, end exclusive. Use blocked_windows array of {start, end}. Null disables."
},
+ "schedule_start_time": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Local time that starts alert checks in HH:MM format. Updating this value changes checks after the already scheduled next_check_at. Set null to remove the custom start time. The current next_check_at stays unchanged. Future checks use the alert interval's existing scheduling behavior."
+ },
"skip_weekend": {
"anyOf": [
{