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(workflows): staff email sending suspension switch and suspended banner (#73439)

Meikel Ratz11d876540fb5
diff --git a/frontend/src/scenes/team-activity/teamActivityDescriber.tsx b/frontend/src/scenes/team-activity/teamActivityDescriber.tsx
index 99390c5b231e..3029b8d80d5e 100644
--- a/frontend/src/scenes/team-activity/teamActivityDescriber.tsx
+++ b/frontend/src/scenes/team-activity/teamActivityDescriber.tsx
@@ -774,6 +774,20 @@ export function teamActivityDescriber(logItem: ActivityLogItem, asNotification?:
return { description: null }
}
+ if (logItem.activity === 'email_sending_suspended' || logItem.activity === 'email_sending_unsuspended') {
+ const wasSuspended = logItem.activity === 'email_sending_suspended'
+ const reason = logItem.detail?.context?.reason as string | undefined
+ return {
+ description: (
+ <>
+ <strong className="ph-no-capture">{userNameForLogItem(logItem)}</strong>{' '}
+ {wasSuspended ? 'suspended' : 're-enabled'} workflow email sending on {nameAndLink(logItem)}
+ {wasSuspended && reason ? <> (reason: {reason})</> : null}
+ </>
+ ),
+ }
+ }
+
if (logItem.activity == 'changed' || logItem.activity == 'updated') {
let changes: Description[] = []
let changeSuffix: Description = <>on {nameAndLink(logItem)}</>
diff --git a/posthog/admin/admins/team_admin.py b/posthog/admin/admins/team_admin.py
index 2d50d5f0cd4c..85e413bb1b76 100644
--- a/posthog/admin/admins/team_admin.py
+++ b/posthog/admin/admins/team_admin.py
@@ -39,6 +39,7 @@ from posthog.models import Team
from posthog.models.activity_logging.activity_log import ActivityContextBase, ActivityLog, Detail, log_activity
from posthog.models.group_type_mapping import invalidate_group_types_cache
from posthog.models.remote_config import RemoteConfig
+from posthog.models.team.extensions import get_or_create_team_extension
from posthog.models.team.team import DEPRECATED_ATTRS
from posthog.personhog_client.client import get_personhog_client
from posthog.personhog_client.converters import proto_group_type_mapping_to_dict
@@ -48,6 +49,7 @@ from posthog.personhog_client.proto import (
UpdateGroupTypeMappingRequest,
)
from posthog.storage.gateway_credential_cache import validate_overspend_allowance_usd
+from posthog.tasks.email import send_email_sending_suspended, send_email_sending_unsuspended
from posthog.temporal.common.client import sync_connect
from posthog.temporal.common.search_attributes import POSTHOG_TEAM_ID_KEY
from posthog.temporal.session_replay.delete_recordings.object_storage import store_session_id_chunks
@@ -59,6 +61,15 @@ from posthog.temporal.session_replay.delete_recordings.types import (
RecordingsWithTeamInput,
)
+from products.notifications.backend.facade.api import (
+ NotificationData,
+ NotificationType,
+ Priority,
+ TargetType,
+ create_notification,
+)
+from products.workflows.backend.models.team_workflows_config import TeamWorkflowsConfig
+
logger = get_logger()
# Upper bound on a single admin AI gateway top-up, to catch fat-fingered amounts.
@@ -70,6 +81,11 @@ class ReplayActivityContext(ActivityContextBase):
reason: str
[email protected](frozen=True)
+class EmailSendingSuspensionActivityContext(ActivityContextBase):
+ reason: str
+
+
@dataclasses.dataclass(frozen=True)
class AIGatewayCreditActivityContext(ActivityContextBase):
amount_usd: str
@@ -153,6 +169,8 @@ class TeamAdmin(admin.ModelAdmin):
"ai_gateway_credit_history",
"policy_cache_blob",
"group_type_mappings_display",
+ "email_sending_suspension_state",
+ "email_sending_suspension_actions",
]
exclude = DEPRECATED_ATTRS
@@ -303,6 +321,22 @@ class TeamAdmin(admin.ModelAdmin):
),
},
),
+ (
+ "Workflow email sending",
+ {
+ "classes": ["collapse"],
+ "fields": [
+ "email_sending_suspension_state",
+ "email_sending_suspension_actions",
+ ],
+ "description": mark_safe(
+ "Kill switch for all workflow email from this team, used when its sender reputation "
+ "(hard bounce / spam complaint rates) endangers shared SES deliverability. Suspending "
+ "notifies the team by email and in-app; the CDP email worker picks the flag up within "
+ "a few minutes."
+ ),
+ },
+ ),
]
def organization_link(self, team: Team):
@@ -646,6 +680,210 @@ class TeamAdmin(admin.ModelAdmin):
self._refresh_ai_gateway_policy_cache(team)
return redirect(reverse("admin:posthog_team_change", args=[object_id]))
+ def _log_email_suspension_activity(self, request, team: Team, activity: str, reason: str) -> None:
+ log_activity(
+ organization_id=team.organization_id,
+ team_id=team.id,
+ user=request.user,
+ was_impersonated=is_impersonated(request),
+ item_id=team.pk,
+ scope="Team",
+ activity=activity,
+ detail=Detail(
+ name=team.name,
+ type="admin_email_sending_suspension",
+ context=EmailSendingSuspensionActivityContext(reason=reason),
+ ),
+ )
+
+ def _notify_email_suspension_changed(self, team: Team, suspended: bool, reason: str) -> None:
+ create_notification(
+ NotificationData(
+ team_id=team.id,
+ notification_type=NotificationType.EMAIL_REPUTATION,
+ priority=Priority.CRITICAL if suspended else Priority.NORMAL,
+ title=(
+ "Email sending has been suspended for this project"
+ if suspended
+ else "Email sending has been re-enabled for this project"
+ ),
+ body=(
+ f"Reason: {reason}. Check the Reputation tab and contact support to get sending re-enabled."
+ if suspended
+ else "Your workflows can deliver email again. Keep bounce and complaint rates low to stay enabled."
+ ),
+ target_type=TargetType.TEAM,
+ target_id=str(team.id),
+ source_url="/workflows/reputation",
+ )
+ )
+
+ def suspend_email_sending_view(self, request, object_id):
+ team = Team.objects.get(pk=object_id)
+ if not self.has_change_permission(request, team):
+ raise PermissionDenied
+
+ suspend_url = reverse("admin:posthog_team_suspend_email_sending", args=[object_id])
+ team_url = reverse("admin:posthog_team_change", args=[object_id])
+
+ if request.method == "GET":
+ context = {
+ **self.admin_site.each_context(request),
+ "team": team,
+ "title": f"Suspend email sending - {team.name}",
+ }
+ return render(request, "admin/posthog/team/suspend_email_sending_form.html", context)
+
+ if request.method != "POST":
+ return HttpResponseNotAllowed(["POST"])
+
+ reason = request.POST.get("reason", "").strip()
+ if not reason:
+ messages.error(request, "Reason is required")
+ return redirect(suspend_url)
+
+ # Row-lock the config while checking + flipping so two concurrent submits (retried POST,
+ # two open admin tabs) can't both pass the idempotency check and both dispatch the
+ # customer email + notification. Side effects stay outside the atomic block.
+ get_or_create_team_extension(team, TeamWorkflowsConfig)
+ with transaction.atomic():
+ config = TeamWorkflowsConfig.objects.select_for_update().get(team_id=team.pk)
+ if config.email_sending_suspended_at is not None:
+ already_suspended_at = config.email_sending_suspended_at
+ suspended_at = None
+ else:
+ already_suspended_at = None
+ suspended_at = timezone.now()
+ config.email_sending_suspended_at = suspended_at
+ config.email_sending_suspension_reason = reason
+ config.save(update_fields=["email_sending_suspended_at", "email_sending_suspension_reason"])
+
+ if already_suspended_at is not None:
+ self.message_user(
+ request,
+ f"Email sending for team '{team.name}' was already suspended "
+ f"(since {already_suspended_at.isoformat()}).",
+ level=messages.INFO,
+ )
+ return redirect(team_url)
+
+ assert suspended_at is not None
+ logger.info(
+ "admin_suspend_email_sending",
+ team_id=team.id,
+ reason=reason,
+ triggered_by=request.user.email,
+ )
+ self._log_email_suspension_activity(request, team, "email_sending_suspended", reason)
+ # Best-effort side effects: the state flip has already committed, and the idempotency
+ # guard would silently skip a retry. Log the failure and let the admin know rather than
+ # 500-ing on a broker/DB hiccup and stranding the state without a customer notification.
+ try:
+ send_email_sending_suspended.delay(team_id=team.id, reason=reason, suspended_at=suspended_at.isoformat())
+ self._notify_email_suspension_changed(team, suspended=True, reason=reason)
+ except Exception:
+ logger.exception("admin_suspend_email_sending_notify_failed", team_id=team.id)
+ self.message_user(
+ request,
+ f"Suspended team '{team.name}', but sending the customer email/notification failed. "
+ "Check logs and follow up manually.",
+ level=messages.ERROR,
+ )
+ return redirect(team_url)
+ self.message_user(
+ request,
+ f"Suspended workflow email sending for team '{team.name}'. "
+ "Workers pick this up within a few minutes; the team has been notified.",
+ level=messages.WARNING,
+ )
+ return redirect(team_url)
+
+ def unsuspend_email_sending_view(self, request, object_id):
+ if request.method != "POST":
+ return HttpResponseNotAllowed(["POST"])
+
+ team = Team.objects.get(pk=object_id)
+ if not self.has_change_permission(request, team):
+ raise PermissionDenied
+
+ team_url = reverse("admin:posthog_team_change", args=[object_id])
+ # Symmetric to suspend: lock the row, re-check, flip inside the transaction so racing
+ # submits can't both fire the re-enable side effects.
+ with transaction.atomic():
+ config = TeamWorkflowsConfig.objects.select_for_update().filter(team_id=team.pk).first()
+ if not config or config.email_sending_suspended_at is None:
+ was_suspended = False
+ unsuspended_at = None
+ else:
+ was_suspended = True
+ unsuspended_at = timezone.now()
+ config.email_sending_suspended_at = None
+ config.email_sending_suspension_reason = ""
+ config.save(update_fields=["email_sending_suspended_at", "email_sending_suspension_reason"])
+
+ if not was_suspended:
+ self.message_user(request, f"Email sending for team '{team.name}' is not suspended.", level=messages.INFO)
+ return redirect(team_url)
+
+ assert unsuspended_at is not None
+ logger.info(
+ "admin_unsuspend_email_sending",
+ team_id=team.id,
+ triggered_by=request.user.email,
+ )
+ self._log_email_suspension_activity(request, team, "email_sending_unsuspended", "")
+ try:
+ send_email_sending_unsuspended.delay(team_id=team.id, unsuspended_at=unsuspended_at.isoformat())
+ self._notify_email_suspension_changed(team, suspended=False, reason="")
+ except Exception:
+ logger.exception("admin_unsuspend_email_sending_notify_failed", team_id=team.id)
+ self.message_user(
+ request,
+ f"Re-enabled sending for team '{team.name}', but the customer email/notification failed. "
+ "Check logs and follow up manually.",
+ level=messages.ERROR,
+ )
+ return redirect(team_url)
+ self.message_user(
+ request,
+ f"Re-enabled workflow email sending for team '{team.name}'. The team has been notified.",
+ level=messages.SUCCESS,
+ )
+ return redirect(team_url)
+
+ @admin.display(description="Email sending state")
+ def email_sending_suspension_state(self, team: Team):
+ if not team.pk:
+ return "-"
+ config = TeamWorkflowsConfig.objects.filter(team_id=team.pk).first()
+ if config and config.email_sending_suspended_at:
+ return format_html(
+ '<span style="color:red"><strong>Suspended</strong></span> at {} — {}',
+ config.email_sending_suspended_at.isoformat(),
+ config.email_sending_suspension_reason or "no reason recorded",
+ )
+ return format_html("<em>Sending enabled</em>")
+
+ @admin.display(description="Email sending actions")
+ def email_sending_suspension_actions(self, team: Team):
+ if not team.pk:
+ return "-"
+ config = TeamWorkflowsConfig.objects.filter(team_id=team.pk).first()
+ is_suspended = bool(config and config.email_sending_suspended_at)
+ # nosemgrep: python.django.security.audit.avoid-mark-safe.avoid-mark-safe (admin-only, renders trusted template)
+ return mark_safe(
+ render_to_string(
+ "admin/posthog/team/email_sending_suspension_actions.html",
+ {
+ "team": team,
+ "suspend_url": reverse("admin:posthog_team_suspend_email_sending", args=[team.pk]),
+ "unsuspend_url": reverse("admin:posthog_team_unsuspend_email_sending", args=[team.pk]),
+ "team_name_escaped": escapejs(team.name),
+ "is_suspended": is_suspended,
+ },
+ )
+ )
+
def add_ai_gateway_credit_view(self, request, object_id):
team = Team.objects.get(pk=object_id)
if not self.has_change_permission(request, team):
@@ -949,6 +1187,16 @@ class TeamAdmin(admin.ModelAdmin):
self.admin_site.admin_view(self.ai_gateway_wallet_view),
name="posthog_team_ai_gateway_wallet",
),
+ path(
+ "<path:object_id>/suspend-email-sending/",
+ self.admin_site.admin_view(self.suspend_email_sending_view),
+ name="posthog_team_suspend_email_sending",
+ ),
+ path(
+ "<path:object_id>/unsuspend-email-sending/",
+ self.admin_site.admin_view(self.unsuspend_email_sending_view),
+ name="posthog_team_unsuspend_email_sending",
+ ),
]
return custom_urls + urls
diff --git a/posthog/admin/inlines/team_inline.py b/posthog/admin/inlines/team_inline.py
index 077d141b3332..4bc16b7354ba 100644
--- a/posthog/admin/inlines/team_inline.py
+++ b/posthog/admin/inlines/team_inline.py
@@ -55,6 +55,8 @@ class TeamInline(TabularInlinePaginated):
"ai_gateway_credit_history",
"policy_cache_blob",
"group_type_mappings_display",
+ "email_sending_suspension_state",
+ "email_sending_suspension_actions",
)
] + ["displayed_name"]
diff --git a/posthog/admin/test_team_admin.py b/posthog/admin/test_team_admin.py
index 1f87bfee894d..08bdba72c402 100644
--- a/posthog/admin/test_team_admin.py
+++ b/posthog/admin/test_team_admin.py
@@ -27,6 +27,8 @@ from posthog.models import Organization
from posthog.models.activity_logging.activity_log import ActivityLog
from posthog.models.team.team import Team
+from products.workflows.backend.models.team_workflows_config import TeamWorkflowsConfig
+
def _attach_messages(request) -> None:
request.session = {}
@@ -595,6 +597,131 @@ class TestTeamAdminAIGatewayWallet(BaseTest):
assert "no top-ups recorded" in rendered
+class TestTeamAdminEmailSendingSuspension(BaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ self.user.is_staff = True
+ self.user.save()
+ self.factory = RequestFactory()
+ self.admin = TeamAdmin(Team, AdminSite())
+ self.suspend_url = f"/admin/posthog/team/{self.team.pk}/suspend-email-sending/"
+ self.team_change_url = f"/admin/posthog/team/{self.team.pk}/change/"
+
+ reverse_patcher = patch(
+ "posthog.admin.admins.team_admin.reverse",
+ side_effect=lambda name, args=None, kwargs=None: (
+ self.team_change_url if name == "admin:posthog_team_change" else self.suspend_url
+ ),
+ )
+ reverse_patcher.start()
+ self.addCleanup(reverse_patcher.stop)
+
+ suspend_email_patcher = patch("posthog.admin.admins.team_admin.send_email_sending_suspended")
+ unsuspend_email_patcher = patch("posthog.admin.admins.team_admin.send_email_sending_unsuspended")
+ notification_patcher = patch("posthog.admin.admins.team_admin.create_notification")
+ self.mock_suspend_email = suspend_email_patcher.start()
+ self.mock_unsuspend_email = unsuspend_email_patcher.start()
+ self.mock_notification = notification_patcher.start()
+ self.addCleanup(suspend_email_patcher.stop)
+ self.addCleanup(unsuspend_email_patcher.stop)
+ self.addCleanup(notification_patcher.stop)
+
+ def _post(self, data: dict | None = None):
+ request = self.factory.post("/", data or {})
+ request.user = self.user
+ _attach_messages(request)
+ return request
+
+ def _get(self):
+ request = self.factory.get("/")
+ request.user = self.user
+ _attach_messages(request)
+ return request
+
+ def _config(self) -> TeamWorkflowsConfig | None:
+ return TeamWorkflowsConfig.objects.filter(team_id=self.team.pk).first()
+
+ def test_get_renders_reason_form(self) -> None:
+ with patch("posthog.admin.admins.team_admin.render") as mock_render:
+ self.admin.suspend_email_sending_view(self._get(), str(self.team.pk))
+ assert mock_render.call_args.args[1] == "admin/posthog/team/suspend_email_sending_form.html"
+
+ def test_post_without_reason_makes_no_changes(self) -> None:
+ response = self.admin.suspend_email_sending_view(self._post({"reason": " "}), str(self.team.pk))
+ assert response.status_code == 302
+ assert response["Location"] == self.suspend_url
+ config = self._config()
+ assert config is None or config.email_sending_suspended_at is None
+ self.mock_suspend_email.delay.assert_not_called()
+ self.mock_notification.assert_not_called()
+
+ def test_suspend_sets_fields_logs_activity_and_notifies(self) -> None:
+ response = self.admin.suspend_email_sending_view(
+ self._post({"reason": "Hard bounce rate above 5%"}), str(self.team.pk)
+ )
+ assert response.status_code == 302
+ assert response["Location"] == self.team_change_url
+
+ config = self._config()
+ assert config is not None
+ assert config.email_sending_suspended_at is not None
+ assert config.email_sending_suspension_reason == "Hard bounce rate above 5%"
+
+ entry = ActivityLog.objects.get(scope="Team", team_id=self.team.id, activity="email_sending_suspended")
+ assert entry.user == self.user
+ assert (entry.detail or {}).get("context", {}).get("reason") == "Hard bounce rate above 5%"
+
+ assert self.mock_suspend_email.delay.call_args.kwargs["team_id"] == self.team.id
+ assert self.mock_suspend_email.delay.call_args.kwargs["reason"] == "Hard bounce rate above 5%"
+ assert self.mock_notification.call_count == 1
+
+ def test_suspend_is_idempotent(self) -> None:
+ self.admin.suspend_email_sending_view(self._post({"reason": "first"}), str(self.team.pk))
+ response = self.admin.suspend_email_sending_view(self._post({"reason": "second"}), str(self.team.pk))
+ assert response.status_code == 302
+
+ config = self._config()
+ assert config is not None
+ assert config.email_sending_suspension_reason == "first"
+ assert self.mock_suspend_email.delay.call_count == 1
+ assert ActivityLog.objects.filter(scope="Team", activity="email_sending_suspended").count() == 1
+
+ def test_unsuspend_clears_fields_logs_activity_and_notifies(self) -> None:
+ self.admin.suspend_email_sending_view(self._post({"reason": "bad rates"}), str(self.team.pk))
+ self.mock_notification.reset_mock()
+
+ response = self.admin.unsuspend_email_sending_view(self._post(), str(self.team.pk))
+ assert response.status_code == 302
+ assert response["Location"] == self.team_change_url
+
+ config = self._config()
+ assert config is not None
+ assert config.email_sending_suspended_at is None
+ assert config.email_sending_suspension_reason == ""
+
+ assert ActivityLog.objects.filter(scope="Team", activity="email_sending_unsuspended").count() == 1
+ assert self.mock_unsuspend_email.delay.call_args.kwargs["team_id"] == self.team.id
+ assert self.mock_notification.call_count == 1
+
+ def test_unsuspend_is_a_noop_when_not_suspended(self) -> None:
+ response = self.admin.unsuspend_email_sending_view(self._post(), str(self.team.pk))
+ assert response.status_code == 302
+ self.mock_unsuspend_email.delay.assert_not_called()
+ self.mock_notification.assert_not_called()
+ assert not ActivityLog.objects.filter(scope="Team", activity="email_sending_unsuspended").exists()
+
+ @parameterized.expand(
+ [
+ ("suspend", "suspend_email_sending_view"),
+ ("unsuspend", "unsuspend_email_sending_view"),
+ ]
+ )
+ def test_views_require_change_permission(self, _name: str, view_name: str) -> None:
+ with patch.object(self.admin, "has_change_permission", return_value=False):
+ with self.assertRaises(PermissionDenied):
+ getattr(self.admin, view_name)(self._post({"reason": "x"}), str(self.team.pk))
+
+
class TestTeamAdminFormOverspendAllowance(BaseTest):
def _form(self, value, instance=None):
instance = instance or self.team
diff --git a/posthog/models/activity_logging/activity_log.py b/posthog/models/activity_logging/activity_log.py
index a9ecb1a90151..86318c7e063d 100644
--- a/posthog/models/activity_logging/activity_log.py
+++ b/posthog/models/activity_logging/activity_log.py
@@ -421,6 +421,14 @@ activity_visibility_restrictions: list[dict[str, Any]] = [
"exclude_when": {},
"allow_staff": True,
},
+ {
+ # Staff-only email sending suspension flips: the acting staff user must not leak into the
+ # org activity log. The customer is told via email and in-app notification instead.
+ "scope": "Team",
+ "activities": ["email_sending_suspended", "email_sending_unsuspended"],
+ "exclude_when": {},
+ "allow_staff": True,
+ },
{
"scope": "Role",
"activities": ["scim_provisioned", "scim_replaced", "scim_updated", "scim_deprovisioned"],
diff --git a/posthog/tasks/email.py b/posthog/tasks/email.py
index a0c1ea4a3a01..23672c995a70 100644
--- a/posthog/tasks/email.py
+++ b/posthog/tasks/email.py
@@ -36,6 +36,7 @@ from posthog.models.activity_logging.activity_log import ActivityLog
from posthog.models.comment import Comment
from posthog.models.comment.utils import build_comment_item_url
from posthog.models.messaging import MessagingRecord, get_email_hashes
+from posthog.models.scoping import with_team_scope
from posthog.models.utils import UUIDT
from posthog.ph_client import feature_enabled_or_false, get_client, ph_scoped_capture
from posthog.scoping_audit import skip_team_scope_audit
@@ -583,6 +584,76 @@ def send_hog_function_disabled(hog_function_id: str) -> None:
message.send()
+def _get_project_admins_to_notify_of_email_sending_suspension(team: Team) -> list[OrganizationMembership]:
+ # Admin+ only: they're the ones who can act on the issue (contact support, clean up lists).
+ # Everyone else with project access still sees the persistent in-app banner. No
+ # notification-setting gate — the send is failing until action is taken and members must
+ # not be able to mute this.
+ memberships_to_email = []
+ memberships = OrganizationMembership.objects.prefetch_related("user", "organization").filter(
+ organization_id=team.organization_id
+ )
+ for membership in memberships:
+ team_permissions = UserPermissions(membership.user).team(team)
+ effective_level = team_permissions.effective_membership_level_for_parent_membership(
+ membership.organization, membership
+ )
+ if effective_level is not None and effective_level >= OrganizationMembership.Level.ADMIN:
+ memberships_to_email.append(membership)
+ return memberships_to_email
+
+
+@shared_task(**EMAIL_TASK_KWARGS)
+@with_team_scope()
+def send_email_sending_suspended(team_id: int, reason: str, suspended_at: str) -> None:
+ """
+ Tell a team's members that staff suspended workflow email sending for their project.
+ Deliberately not gated by notification settings — sends are failing until they act.
+ """
+ if not is_email_available(with_absolute_urls=True):
+ return
+ team = Team.objects.get(id=team_id)
+ memberships_to_email = _get_project_admins_to_notify_of_email_sending_suspension(team)
+ if not memberships_to_email:
+ return
+ message = EmailMessage(
+ campaign_key=f"email_sending_suspended_{team_id}_{suspended_at}",
+ subject=f"[Action required] Email sending has been suspended for project '{team}'",
+ template_name="email_sending_suspended",
+ template_context={
+ "team": team,
+ "reason": reason,
+ "reputation_path": f"/project/{team.id}/workflows/reputation",
+ },
+ )
+ for membership in memberships_to_email:
+ message.add_user_recipient(membership.user)
+ message.send()
+
+
+@shared_task(**EMAIL_TASK_KWARGS)
+@with_team_scope()
+def send_email_sending_unsuspended(team_id: int, unsuspended_at: str) -> None:
+ if not is_email_available(with_absolute_urls=True):
+ return
+ team = Team.objects.get(id=team_id)
+ memberships_to_email = _get_project_admins_to_notify_of_email_sending_suspension(team)
+ if not memberships_to_email:
+ return
+ message = EmailMessage(
+ campaign_key=f"email_sending_unsuspended_{team_id}_{unsuspended_at}",
+ subject=f"Email sending has been re-enabled for project '{team}'",
+ template_name="email_sending_unsuspended",
+ template_context={
+ "team": team,
+ "reputation_path": f"/project/{team.id}/workflows/reputation",
+ },
+ )
+ for membership in memberships_to_email:
+ message.add_user_recipient(membership.user)
+ message.send()
+
+
def send_batch_export_run_failure(
batch_export_run_id: str | UUIDT,
failure_rate: float = 1.0,
diff --git a/posthog/tasks/test/__snapshots__/test_task_registration.ambr b/posthog/tasks/test/__snapshots__/test_task_registration.ambr
index 2dcb2194b4f3..56d7b8323003 100644
--- a/posthog/tasks/test/__snapshots__/test_task_registration.ambr
+++ b/posthog/tasks/test/__snapshots__/test_task_registration.ambr
@@ -31,6 +31,8 @@
'posthog.tasks.email.send_conversation_restore_email',
'posthog.tasks.email.send_discussions_mentioned',
'posthog.tasks.email.send_email_change_emails',
+ 'posthog.tasks.email.send_email_sending_suspended',
+ 'posthog.tasks.email.send_email_sending_unsuspended',
'posthog.tasks.email.send_email_verification',
'posthog.tasks.email.send_error_tracking_issue_assigned',
'posthog.tasks.email.send_error_tracking_weekly_digest',
diff --git a/posthog/templates/admin/posthog/team/email_sending_suspension_actions.html b/posthog/templates/admin/posthog/team/email_sending_suspension_actions.html
new file mode 100644
index 000000000000..0930bec44093
--- /dev/null
+++ b/posthog/templates/admin/posthog/team/email_sending_suspension_actions.html
@@ -0,0 +1,13 @@
+<div style="margin: 10px 0;">
+ {% if is_suspended %}
+ <button type="submit" name="_unsuspend_email_sending" class="button"
+ formmethod="post" formaction="{{ unsuspend_url }}" formnovalidate
+ onclick="return confirm('Re-enable workflow email sending for {{ team_name_escaped }}? The team will be notified.');">
+ Re-enable email sending</button>
+ {% else %}
+ <a class="button" href="{{ suspend_url }}">Suspend email sending…</a>
+ {% endif %}
+ <p style="margin-top: 8px; color: #666; font-size: 12px;">
+ Sets <code>email_sending_suspended_at</code> on the team's workflows config. Suspending asks for a reason and notifies the team.
+ </p>
+</div>
diff --git a/posthog/templates/admin/posthog/team/suspend_email_sending_form.html b/posthog/templates/admin/posthog/team/suspend_email_sending_form.html
new file mode 100644
index 000000000000..6b0d94545e7b
--- /dev/null
+++ b/posthog/templates/admin/posthog/team/suspend_email_sending_form.html
@@ -0,0 +1,18 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block content %}
+<p>Suspend ALL workflow email sending for <strong>{{ team.name }}</strong>. The CDP email worker blocks every send for this team within a few minutes, and the team is notified by email and in-app. The reason below is shown to the customer.</p>
+
+<form method="post" onsubmit="this.querySelector('input[type=submit]').disabled = true;">
+ {% csrf_token %}
+ <div style="margin: 20px 0;">
+ <label for="reason" style="display: block; margin-bottom: 5px; font-weight: bold;">Reason (customer-visible):</label>
+ <input type="text" id="reason" name="reason" placeholder="e.g. Hard bounce rate above 5% over recent sending" style="width: 500px; padding: 8px;" required />
+ </div>
+ <div style="margin-top: 20px;">
+ <input type="submit" class="default" value="Suspend email sending" style="padding: 10px 20px;" />
+ <a href="{% url 'admin:posthog_team_change' team.pk %}" style="margin-left: 10px;">Cancel</a>
+ </div>
+</form>
+{% endblock %}
diff --git a/posthog/templates/email/email_sending_suspended.html b/posthog/templates/email/email_sending_suspended.html
new file mode 100644
index 000000000000..d7ca62016962
--- /dev/null
+++ b/posthog/templates/email/email_sending_suspended.html
@@ -0,0 +1,32 @@
+{% extends "email/base.html" %} {% load posthog_assets %}
+{% block heading %}Email sending has been suspended{% endblock %}
+{% block section %}
+<!-- prettier-ignore -->
+<p>
+ Workflow email sending for project <b>{{ team }}</b> has been suspended. Emails from your workflows are not being delivered while the suspension is active.
+</p>
+<p>
+ Reason: <b>{{ reason }}</b>
+</p>
+<p>
+ This happens when bounce or spam complaint rates cross critical thresholds and put email deliverability at risk. To get sending re-enabled: open the Reputation tab to find the workflow responsible, remove old or purchased addresses from your lists, stop sending to recipients who never engage, and then contact support.
+</p>
+<div class="mb mt text-center">
+ <a class="button" href="{% absolute_uri reputation_path %}">View reputation</a>
+</div>
+<div class="mt">
+ <p>
+ If the button above doesn't work, paste this link into your browser:<br />
+ <a href="{% absolute_uri reputation_path %}">{% absolute_uri reputation_path %}</a>
+ </p>
+</div>
+{% endblock %}
+
+{% block footer %}
+Need help getting re-enabled?
+<a href="https://posthog.com/questions?{{ utm_tags }}"
+ target="_blank"><b>Contact support</b></a>
+or
+<a href="https://posthog.com/docs?{{ utm_tags }}"
+ target="_blank"><b>read our documentation</b></a>.
+{% endblock %}
diff --git a/posthog/templates/email/email_sending_unsuspended.html b/posthog/templates/email/email_sending_unsuspended.html
new file mode 100644
index 000000000000..0d5ae35d7bd0
--- /dev/null
+++ b/posthog/templates/email/email_sending_unsuspended.html
@@ -0,0 +1,29 @@
+{% extends "email/base.html" %} {% load posthog_assets %}
+{% block heading %}Email sending has been re-enabled{% endblock %}
+{% block section %}
+<!-- prettier-ignore -->
+<p>
+ Workflow email sending for project <b>{{ team }}</b> has been re-enabled. Your workflows can deliver email again.
+</p>
+<p>
+ Keep an eye on the Reputation tab: rates are recalculated daily, and keeping bounce and spam complaint rates low protects your deliverability going forward.
+</p>
+<div class="mb mt text-center">
+ <a class="button" href="{% absolute_uri reputation_path %}">View reputation</a>
+</div>
+<div class="mt">
+ <p>
+ If the button above doesn't work, paste this link into your browser:<br />
+ <a href="{% absolute_uri reputation_path %}">{% absolute_uri reputation_path %}</a>
+ </p>
+</div>
+{% endblock %}
+
+{% block footer %}
+Need help?
+<a href="https://posthog.com/questions?{{ utm_tags }}"
+ target="_blank"><b>Visit support</b></a>
+or
+<a href="https://posthog.com/docs?{{ utm_tags }}"
+ target="_blank"><b>read our documentation</b></a>.
+{% endblock %}
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index 907645aa8d0f..40a6baf690ea 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -95,6 +95,7 @@ from products.workflows.backend.models.hog_flow.hog_flow import (
from products.workflows.backend.models.hog_flow_batch_job import HogFlowBatchJob
from products.workflows.backend.models.hog_flow_revision import HogFlowRevision
from products.workflows.backend.models.hog_flow_schedule import SCHEDULED_TRIGGER_TYPES, HogFlowSchedule
+from products.workflows.backend.models.team_workflows_config import TeamWorkflowsConfig
from products.workflows.backend.services.batch_audience import (
PERSON_BATCH_SIZE as WORKFLOWS_PERSON_BATCH_SIZE,
SUPPORTED_DEDUPE_KEYS,
@@ -1220,6 +1221,39 @@ class TeamEmailReputationResponseSerializer(serializers.Serializer):
"Latest snapshot per workflow, worst state and highest rates first, capped at the worst 50 workflows."
),
)
+ email_sending_suspended = serializers.BooleanField(
+ read_only=True,
+ help_text="True while workflow email sending is suspended for this project to protect deliverability.",
+ )
+ email_sending_suspended_at = serializers.DateTimeField(
+ read_only=True,
+ allow_null=True,
+ help_text="When email sending was suspended; null while sending is enabled.",
+ )
+ email_sending_suspension_reason = serializers.CharField(
+ read_only=True,
+ allow_blank=True,
+ help_text="Staff-authored reason shown to customers alongside the suspension notice; empty when not suspended.",
+ )
+
+
+class EmailSendingSuspensionStatusSerializer(serializers.Serializer):
+ """Cheap suspension-only read for the persistent scene-wide banner — no reputation computation."""
+
+ email_sending_suspended = serializers.BooleanField(
+ read_only=True,
+ help_text="True while workflow email sending is suspended for this project to protect deliverability.",
+ )
+ email_sending_suspended_at = serializers.DateTimeField(
+ read_only=True,
+ allow_null=True,
+ help_text="When email sending was suspended; null while sending is enabled.",
+ )
+ email_sending_suspension_reason = serializers.CharField(
+ read_only=True,
+ allow_blank=True,
+ help_text="Staff-authored reason shown to customers alongside the suspension notice; empty when not suspended.",
+ )
class HogFlowMinimalSerializer(UserAccessControlSerializerMixin, serializers.ModelSerializer):
@@ -2010,6 +2044,7 @@ class HogFlowViewSet(
"metrics_totals",
"metrics_global",
"team_reputation",
+ "email_sending_suspension",
"user_blast_radius",
"assets",
"asset_content",
@@ -3285,16 +3320,64 @@ class HogFlowViewSet(
)
workflow_snapshots = workflow_snapshots[: self.WORKFLOW_REPUTATION_LIMIT]
+ # Shown to every project member regardless of per-object grants: a suspension stops
+ # everyone's email, so hiding it would just leave silent send failures unexplained.
+ suspension = (
+ TeamWorkflowsConfig.objects.filter(team_id=self.team_id)
+ .values("email_sending_suspended_at", "email_sending_suspension_reason")
+ .first()
+ )
+ suspended_at = suspension["email_sending_suspended_at"] if suspension else None
+ suspension_reason = suspension["email_sending_suspension_reason"] if suspension else ""
+
return Response(
TeamEmailReputationResponseSerializer(
{
"reputation": latest,
"workflows": workflow_snapshots,
+ "email_sending_suspended": suspended_at is not None,
+ "email_sending_suspended_at": suspended_at,
+ "email_sending_suspension_reason": suspension_reason if suspended_at is not None else "",
},
context={"workflow_history": history_by_flow},
).data
)
+ @extend_schema(
+ operation_id="hog_flows_email_sending_suspension_retrieve",
+ responses={200: EmailSendingSuspensionStatusSerializer},
+ )
+ @action(
+ detail=False,
+ methods=["GET"],
+ pagination_class=None,
+ filter_backends=[],
+ url_path="email_sending_suspension",
+ )
+ def email_sending_suspension(self, request: Request, **kwargs) -> Response:
+ """
+ Cheap read for the scene-wide suspension banner: single-row `TeamWorkflowsConfig` lookup
+ with no reputation computation. Every project member sees this — a suspension stops
+ everyone's email, so hiding it would leave silent send failures unexplained.
+ """
+ suspension = (
+ TeamWorkflowsConfig.objects.filter(team_id=self.team_id)
+ .values("email_sending_suspended_at", "email_sending_suspension_reason")
+ .first()
+ )
+ suspended_at = suspension["email_sending_suspended_at"] if suspension else None
+ return Response(
+ EmailSendingSuspensionStatusSerializer(
+ {
+ "email_sending_suspended": suspended_at is not None,
+ "email_sending_suspended_at": suspended_at,
+ "email_sending_suspension_reason": (
+ suspension["email_sending_suspension_reason"] if suspension and suspended_at is not None else ""
+ ),
+ }
+ ).data
+ )
+
@extend_schema(methods=["GET"], responses=HogFlowBatchJobSerializer(many=True))
@extend_schema(methods=["POST"], request=HogFlowBatchJobSerializer, responses=HogFlowBatchJobSerializer)
# GET returns a bare list (no pagination) and ignores the viewset's HogFlow filterset; disable both so the
diff --git a/products/workflows/backend/api/test/test_email_reputation.py b/products/workflows/backend/api/test/test_email_reputation.py
index ccbd60833c09..ec1515253b79 100644
--- a/products/workflows/backend/api/test/test_email_reputation.py
+++ b/products/workflows/backend/api/test/test_email_reputation.py
@@ -9,6 +9,7 @@ from rest_framework import status
from posthog.models import Team
from products.workflows.backend.models import EmailReputationSnapshot, HogFlow
+from products.workflows.backend.models.team_workflows_config import TeamWorkflowsConfig
RUN_2 = timezone.now().replace(microsecond=0) - timedelta(days=1)
RUN_1 = RUN_2 - timedelta(days=1)
@@ -41,7 +42,30 @@ class TestEmailReputationAPI(APIBaseTest):
def test_reputation_endpoint_returns_empty_shape_before_first_evaluation(self):
response = self.client.get(f"/api/projects/{self.team.id}/hog_flows/reputation")
assert response.status_code == status.HTTP_200_OK
- assert response.json() == {"reputation": None, "workflows": []}
+ assert response.json() == {
+ "reputation": None,
+ "workflows": [],
+ "email_sending_suspended": False,
+ "email_sending_suspended_at": None,
+ "email_sending_suspension_reason": "",
+ }
+
+ def test_reputation_endpoint_reports_email_sending_suspension(self):
+ suspended_at = timezone.now().replace(microsecond=0)
+ TeamWorkflowsConfig.objects.update_or_create(
+ team=self.team,
+ defaults={
+ "email_sending_suspended_at": suspended_at,
+ "email_sending_suspension_reason": "critical bounce rate",
+ },
+ )
+
+ response = self.client.get(f"/api/projects/{self.team.id}/hog_flows/reputation")
+ assert response.status_code == status.HTTP_200_OK
+ data = response.json()
+ assert data["email_sending_suspended"] is True
+ assert data["email_sending_suspended_at"] == suspended_at.isoformat().replace("+00:00", "Z")
+ assert data["email_sending_suspension_reason"] == "critical bounce rate"
def test_reputation_endpoint_search_filters_before_the_cap(self):
# A healthy workflow pushed past the worst-50 cap must still be findable by name
@@ -123,4 +147,10 @@ class TestEmailReputationAPI(APIBaseTest):
response = self.client.get(f"/api/projects/{self.team.id}/hog_flows/reputation")
assert response.status_code == status.HTTP_200_OK
# Nothing from the other team leaks: no aggregate, no workflow rows
- assert response.json() == {"reputation": None, "workflows": []}
+ assert response.json() == {
+ "reputation": None,
+ "workflows": [],
+ "email_sending_suspended": False,
+ "email_sending_suspended_at": None,
+ "email_sending_suspension_reason": "",
+ }
diff --git a/products/workflows/frontend/WorkflowsScene.tsx b/products/workflows/frontend/WorkflowsScene.tsx
index e28070553a9c..a05d49bb06f6 100644
--- a/products/workflows/frontend/WorkflowsScene.tsx
+++ b/products/workflows/frontend/WorkflowsScene.tsx
@@ -2,7 +2,7 @@ import { MakeLogicType, actions, connect, kea, path, props, reducers, selectors,
import { urlToAction } from 'kea-router'
import { IconApple, IconAndroid, IconLetter, IconPlusSmall } from '@posthog/icons'
-import { LemonButton, LemonMenu, LemonMenuItems } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, LemonMenu, LemonMenuItems, Link } from '@posthog/lemon-ui'
import api from 'lib/api'
import { AccessControlAction } from 'lib/components/AccessControlAction'
@@ -35,6 +35,7 @@ import { newWorkflowLogic } from './Workflows/newWorkflowLogic'
import { NewWorkflowModal } from './Workflows/NewWorkflowModal'
import { WorkflowsReputation } from './Workflows/Reputation/WorkflowsReputation'
import { WorkflowsTable } from './Workflows/WorkflowsTable'
+import { workflowsEmailSuspensionLogic } from './workflowsEmailSuspensionLogic'
const WORKFLOW_SCENE_TABS = ['workflows', 'library', 'channels', 'opt-outs', 'suppression', 'reputation'] as const
export type WorkflowsSceneTab = (typeof WORKFLOW_SCENE_TABS)[number]
@@ -142,6 +143,7 @@ export const scene: SceneExport<WorkflowsSceneProps> = {
export function WorkflowsScene(props: WorkflowsSceneProps = {}): JSX.Element {
const { currentTab } = useValues(workflowsSceneLogic(props))
+ const { emailSendingSuspended, emailSendingSuspensionReason } = useValues(workflowsEmailSuspensionLogic)
const { featureFlags } = useValues(featureFlagLogic)
const { openSetupModal } = useActions(integrationsLogic)
const { openNewCategoryModal } = useActions(optOutCategoriesLogic)
@@ -324,6 +326,19 @@ export function WorkflowsScene(props: WorkflowsSceneProps = {}): JSX.Element {
</>
}
/>
+ {emailSendingSuspended && (
+ <LemonBanner type="error" data-attr="workflows-email-suspended-banner">
+ Email sending is suspended for this project. Workflow emails are not being delivered.
+ {emailSendingSuspensionReason ? <> Reason: {emailSendingSuspensionReason}.</> : null}{' '}
+ {emailReputationEnabled && (
+ <>
+ Review the <Link to={urls.workflows('reputation')}>Reputation tab</Link>
+ {' and '}
+ </>
+ )}
+ contact support to get sending re-enabled.
+ </LemonBanner>
+ )}
<LemonTabs activeKey={currentTab} tabs={tabs} sceneInset data-attr="workflows-scene-tabs" />
<NewWorkflowModal />
</SceneContent>
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index d0f60f812622..2bf386b82dee 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -1033,6 +1033,21 @@ export interface PatchedHogFlowScheduleApi {
readonly updated_at?: string
}
+/**
+ * Cheap suspension-only read for the persistent scene-wide banner — no reputation computation.
+ */
+export interface EmailSendingSuspensionStatusApi {
+ /** True while workflow email sending is suspended for this project to protect deliverability. */
+ readonly email_sending_suspended: boolean
+ /**
+ * When email sending was suspended; null while sending is enabled.
+ * @nullable
+ */
+ readonly email_sending_suspended_at: string | null
+ /** Staff-authored reason shown to customers alongside the suspension notice; empty when not suspended. */
+ readonly email_sending_suspension_reason: string
+}
+
export interface WorkflowStatsRowApi {
/** The workflow these counts are for. */
workflow_id: string
@@ -1134,6 +1149,15 @@ export interface TeamEmailReputationResponseApi {
readonly reputation: EmailReputationSnapshotApi | null
/** Latest snapshot per workflow, worst state and highest rates first, capped at the worst 50 workflows. */
readonly workflows: readonly WorkflowEmailReputationSnapshotApi[]
+ /** True while workflow email sending is suspended for this project to protect deliverability. */
+ readonly email_sending_suspended: boolean
+ /**
+ * When email sending was suspended; null while sending is enabled.
+ * @nullable
+ */
+ readonly email_sending_suspended_at: string | null
+ /** Staff-authored reason shown to customers alongside the suspension notice; empty when not suspended. */
+ readonly email_sending_suspension_reason: string
}
/**
diff --git a/products/workflows/frontend/generated/api.ts b/products/workflows/frontend/generated/api.ts
index 06ef293a5a94..704caec5888e 100644
--- a/products/workflows/frontend/generated/api.ts
+++ b/products/workflows/frontend/generated/api.ts
@@ -13,6 +13,7 @@ import type {
AppMetricsTotalsResponseApi,
BlastRadiusApi,
BlastRadiusRequestApi,
+ EmailSendingSuspensionStatusApi,
HogFlowApi,
HogFlowBatchJobApi,
HogFlowInvocationApi,
@@ -811,6 +812,25 @@ export const hogFlowsBulkDeleteCreate = async (
})
}
+export const getHogFlowsEmailSendingSuspensionRetrieveUrl = (projectId: string) => {
+ return `/api/projects/${projectId}/hog_flows/email_sending_suspension/`
+}
+
+/**
+ * Cheap read for the scene-wide suspension banner: single-row `TeamWorkflowsConfig` lookup
+ * with no reputation computation. Every project member sees this — a suspension stops
+ * everyone's email, so hiding it would leave silent send failures unexplained.
+ */
+export const hogFlowsEmailSendingSuspensionRetrieve = async (
+ projectId: string,
+ options?: RequestInit
+): Promise<EmailSendingSuspensionStatusApi> => {
+ return apiMutator<EmailSendingSuspensionStatusApi>(getHogFlowsEmailSendingSuspensionRetrieveUrl(projectId), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getHogFlowsMetricsGlobalRetrieveUrl = (
projectId: string,
params?: HogFlowsMetricsGlobalRetrieveParams
diff --git a/products/workflows/frontend/workflowsEmailSuspensionLogic.ts b/products/workflows/frontend/workflowsEmailSuspensionLogic.ts
new file mode 100644
index 000000000000..e03f2fa3aba7
--- /dev/null
+++ b/products/workflows/frontend/workflowsEmailSuspensionLogic.ts
@@ -0,0 +1,83 @@
+import { MakeLogicType, afterMount, connect, kea, path, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { projectLogic } from 'scenes/projectLogic'
+
+import { hogFlowsEmailSendingSuspensionRetrieve } from 'products/workflows/frontend/generated/api'
+import type { EmailSendingSuspensionStatusApi } from 'products/workflows/frontend/generated/api.schemas'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface workflowsEmailSuspensionLogicValues {
+ currentProjectId: number | null // projectLogic
+ emailSendingSuspended: boolean
+ emailSendingSuspensionReason: string
+ suspensionStatus: EmailSendingSuspensionStatusApi | null
+ suspensionStatusLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface workflowsEmailSuspensionLogicActions {
+ loadSuspensionStatus: () => any
+ loadSuspensionStatusFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSuspensionStatusSuccess: (
+ suspensionStatus: EmailSendingSuspensionStatusApi | null,
+ payload?: any
+ ) => {
+ suspensionStatus: EmailSendingSuspensionStatusApi | null
+ payload?: any
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface workflowsEmailSuspensionLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ emailSendingSuspended: (suspensionStatus: EmailSendingSuspensionStatusApi | null) => boolean
+ emailSendingSuspensionReason: (suspensionStatus: EmailSendingSuspensionStatusApi | null) => string
+ }
+}
+
+export type workflowsEmailSuspensionLogicType = MakeLogicType<
+ workflowsEmailSuspensionLogicValues,
+ workflowsEmailSuspensionLogicActions,
+ Record<string, any>,
+ workflowsEmailSuspensionLogicMeta
+>
+
+export const workflowsEmailSuspensionLogic = kea<workflowsEmailSuspensionLogicType>([
+ path(['products', 'workflows', 'frontend', 'workflowsEmailSuspensionLogic']),
+ connect(() => ({
+ values: [projectLogic, ['currentProjectId']],
+ })),
+ loaders(({ values }) => ({
+ suspensionStatus: [
+ null as EmailSendingSuspensionStatusApi | null,
+ {
+ loadSuspensionStatus: async () => {
+ if (!values.currentProjectId) {
+ return null
+ }
+ return await hogFlowsEmailSendingSuspensionRetrieve(String(values.currentProjectId))
+ },
+ },
+ ],
+ })),
+ selectors({
+ emailSendingSuspended: [
+ (s) => [s.suspensionStatus],
+ (status: EmailSendingSuspensionStatusApi | null): boolean => status?.email_sending_suspended ?? false,
+ ],
+ emailSendingSuspensionReason: [
+ (s) => [s.suspensionStatus],
+ (status: EmailSendingSuspensionStatusApi | null): string => status?.email_sending_suspension_reason ?? '',
+ ],
+ }),
+ afterMount(({ actions }) => {
+ actions.loadSuspensionStatus()
+ }),
+])
diff --git a/products/workflows/mcp/tools.yaml b/products/workflows/mcp/tools.yaml
index 8a853500b068..82475611ca30 100644
--- a/products/workflows/mcp/tools.yaml
+++ b/products/workflows/mcp/tools.yaml
@@ -57,6 +57,9 @@ tools:
hog-flows-discard-draft-create:
operation: hog_flows_discard_draft_create
enabled: false
+ hog-flows-email-sending-suspension-retrieve:
+ operation: hog_flows_email_sending_suspension_retrieve
+ enabled: false
hog-flows-invocations-create:
operation: hog_flows_invocations_create
enabled: false
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5e286082ad35..0279d965b098 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -23231,6 +23231,21 @@ export namespace Schemas {
readonly evaluated_at: string;
}
+ /**
+ * Cheap suspension-only read for the persistent scene-wide banner — no reputation computation.
+ */
+ export interface EmailSendingSuspensionStatus {
+ /** True while workflow email sending is suspended for this project to protect deliverability. */
+ readonly email_sending_suspended: boolean;
+ /**
+ * When email sending was suspended; null while sending is enabled.
+ * @nullable
+ */
+ readonly email_sending_suspended_at: string | null;
+ /** Staff-authored reason shown to customers alongside the suspension notice; empty when not suspended. */
+ readonly email_sending_suspension_reason: string;
+ }
+
/**
* Highest htmlID suffix per element type, e.g. {"u_row": 1, "u_content_text": 2}.
*/
@@ -69087,6 +69102,15 @@ export namespace Schemas {
readonly reputation: EmailReputationSnapshot | null;
/** Latest snapshot per workflow, worst state and highest rates first, capped at the worst 50 workflows. */
readonly workflows: readonly WorkflowEmailReputationSnapshot[];
+ /** True while workflow email sending is suspended for this project to protect deliverability. */
+ readonly email_sending_suspended: boolean;
+ /**
+ * When email sending was suspended; null while sending is enabled.
+ * @nullable
+ */
+ readonly email_sending_suspended_at: string | null;
+ /** Staff-authored reason shown to customers alongside the suspension notice; empty when not suspended. */
+ readonly email_sending_suspension_reason: string;
}
export interface TeamMergeTrendPoint {