: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(subscriptions): tell agents where each delivery_config option applies (#101521)
posthog[bot]570e00941e3b
diff --git a/ee/api/subscription.py b/ee/api/subscription.pyindex 0098e5effb64..f9ec9363ebf0 100644--- a/ee/api/subscription.py+++ b/ee/api/subscription.py@@ -48,7 +48,7 @@ from posthog.security.url_validation import is_microsoft_teams_webhook_urlfrom posthog.slo.context import SloSpec, slo_operationfrom posthog.slo.types import SloArea, SloOperationfrom posthog.temporal.common.client import sync_connect-from posthog.utils import str_to_bool+from posthog.utils import human_list, str_to_boolfrom products.access_control.backend.facade.user_access_control import UserAccessControlfrom products.dashboards.backend.models.dashboard import Dashboard@@ -91,6 +91,12 @@ MAX_AI_SUBSCRIPTION_CONTEXTS: int = int(SubscriptionAIContextLimit.model_fields[AI_DELIVERY_DISPLAY_FIELDS = frozenset({"include_images", "include_feedback", "include_manage_link", "include_posthog_hint"})+# An agent reads one field's description in isolation, so every field repeats the scope rule.+_AI_DISPLAY_FIELD_SCOPE_NOTE = (+ "The request is rejected when the subscription sets insight or dashboard instead of prompt. "+ "It does not control the AI summary on an insight or dashboard subscription: use "+ "summary_enabled and summary_prompt_guide for that."+)def _capture_post_write_failure(exc: Exception) -> None:@@ -297,29 +303,35 @@ class DeliveryConfigSerializer(serializers.Serializer):required=False,default=False,help_text=(- "Slack only: when true, upload all insight images together in the main Slack message "- "instead of posting the first image in the main message and the rest as threaded replies. "- "Defaults to false."+ "Slack insight and dashboard subscriptions only: when true, upload all insight images "+ "together in the main Slack message instead of posting the first image in the main "+ "message and the rest as threaded replies. Defaults to false. The request is rejected "+ "when target_type is not 'slack', when the subscription sets prompt instead of insight "+ "or dashboard, or when the Slack integration does not hold the files:write permission. "+ "Omit it unless the user asks for one combined message."),)include_images = serializers.BooleanField(required=False,- help_text="AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.",+ help_text="Prompt subscriptions only: include generated chart images. Defaults to true when omitted. "+ + _AI_DISPLAY_FIELD_SCOPE_NOTE,)include_feedback = serializers.BooleanField(required=False,- help_text="AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.",+ help_text="Prompt subscriptions only: include report feedback links. Defaults to true when omitted. "+ + _AI_DISPLAY_FIELD_SCOPE_NOTE,)include_manage_link = serializers.BooleanField(required=False,- help_text="AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.",+ help_text="Prompt subscriptions only: include a link to manage the subscription. "+ "Defaults to true when omitted. " + _AI_DISPLAY_FIELD_SCOPE_NOTE,)include_posthog_hint = serializers.BooleanField(required=False,- help_text=(- "AI prompt subscriptions only: include PostHog product guidance. Slack only. "- "Email and Microsoft Teams reports do not include it. Defaults to true when omitted."- ),+ help_text="Prompt subscriptions only: include PostHog product guidance. Defaults to true when "+ "omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it "+ "out and accept the option without an error, unlike post_all_insights_in_main_message. "+ + _AI_DISPLAY_FIELD_SCOPE_NOTE,)@@ -450,7 +462,12 @@ class SubscriptionWriteSerializer(serializers.ModelSerializer):)delivery_config = DeliveryConfigSerializer(required=False,- help_text="Per-delivery rendering options. Each option documents which delivery targets it applies to.",+ help_text=(+ "Per-delivery rendering options. Every option applies to one subscription kind or delivery "+ "target only, and each option's own description says where it applies and whether a "+ "mismatch is rejected or ignored. Omit this field unless the user asks for one of the "+ "options."+ ),)insight_short_id = serializers.SerializerMethodField()resource_name = serializers.SerializerMethodField()@@ -766,6 +783,10 @@ class SubscriptionWriteSerializer(serializers.ModelSerializer):)except ValueError as exc:raise ValidationError(str(exc))+ # The prompt merge below folds the stored config into `attrs`, so keep what the caller+ # actually sent. A stored option that the request never names must not reject the+ # request, because that leaves the row impossible to edit.+ submitted_delivery_config = attrs.get("delivery_config") or {}if (resource_type == Subscription.ResourceType.AI_PROMPTand self.partial@@ -785,7 +806,14 @@ class SubscriptionWriteSerializer(serializers.ModelSerializer):if validate_for_resource_type is None:raise ValidationError({"resource_type": [f"Unsupported resource_type: {resource_type}."]})if resource_type != Subscription.ResourceType.AI_PROMPT and attrs.get("ai_prompt_config"):- raise ValidationError({"ai_prompt_config": ["AI report settings only apply to AI subscriptions."]})+ raise ValidationError(+ {+ "ai_prompt_config": [+ "ai_prompt_config only applies to prompt subscriptions. This subscription has "+ f"resource_type '{resource_type}', so remove it from the request."+ ]+ }+ )if "contexts" in attrs:if resource_type != Subscription.ResourceType.AI_PROMPT:if attrs["contexts"]:@@ -821,11 +849,38 @@ class SubscriptionWriteSerializer(serializers.ModelSerializer):if "delivery_config" in attrselse (self.instance.delivery_config if self.instance else None)) or {}- if resource_type != Subscription.ResourceType.AI_PROMPT and any(- field in effective_delivery_config for field in AI_DELIVERY_DISPLAY_FIELDS- ):+ # A prompt report never reads the gallery option, so only the value a request sends can be+ # wrong. An insight or dashboard report does read it, so the stored value still decides: a+ # target or permission change would break the next delivery.+ gallery_enabled = (+ submitted_delivery_config+ if resource_type == Subscription.ResourceType.AI_PROMPT+ else effective_delivery_config+ ).get("post_all_insights_in_main_message")+ if resource_type != Subscription.ResourceType.AI_PROMPT:+ unsupported = sorted(AI_DELIVERY_DISPLAY_FIELDS & submitted_delivery_config.keys())+ if unsupported:+ verb, pronoun = ("applies", "it") if len(unsupported) == 1 else ("apply", "them")+ raise ValidationError(+ {+ "delivery_config": [+ f"{human_list(unsupported)} only {verb} to prompt subscriptions. "+ f"This subscription has resource_type '{resource_type}', "+ f"so remove {pronoun} from delivery_config."+ ]+ }+ )+ elif gallery_enabled:+ # The prompt Slack renderer already posts every chart in the main message and never reads this option.raise ValidationError(- {"delivery_config": ["AI delivery display options are only supported for prompt subscriptions."]}+ {+ "delivery_config": [+ "post_all_insights_in_main_message only applies to insight and dashboard "+ f"subscriptions. This subscription has resource_type '{resource_type}', so "+ "remove it from delivery_config. A prompt report already posts all its chart "+ "images in the main message."+ ]+ })# Reject re-enables of subscriptions whose delivery prerequisite is still@@ -890,24 +945,26 @@ class SubscriptionWriteSerializer(serializers.ModelSerializer):)if integration.kind != "slack":raise ValidationError({"integration_id": ["Slack subscriptions require a Slack integration."]})- if effective_delivery_config.get("post_all_insights_in_main_message") and SlackIntegration(- integration- ).missing_scopes({"files:write"}):+ if gallery_enabled and SlackIntegration(integration).missing_scopes({"files:write"}):raise ValidationError({"delivery_config": [- "Posting all insights in the main message requires the Slack files:write permission. "- "Reconnect Slack to grant it."+ "post_all_insights_in_main_message requires the Slack files:write permission. "+ "Reconnect Slack to grant it, or remove the option from delivery_config to "+ "save the subscription now. Each delivery then posts the first image in the "+ "main message and the rest as threaded replies."]})- if (- effective_delivery_config.get("post_all_insights_in_main_message")- and target_type != Subscription.SubscriptionTarget.SLACK- ):+ if gallery_enabled and target_type != Subscription.SubscriptionTarget.SLACK:raise ValidationError(- {"delivery_config": ["post_all_insights_in_main_message is only supported for Slack subscriptions."]}+ {+ "delivery_config": [+ "post_all_insights_in_main_message only applies to Slack subscriptions. "+ f"This subscription delivers to {target_type}, so remove it from delivery_config."+ ]+ })prompt_guide = attrs.get("summary_prompt_guide")diff --git a/ee/api/test/test_subscription.py b/ee/api/test/test_subscription.pyindex 36f6eda7e8b1..24ffef0a5dba 100644--- a/ee/api/test/test_subscription.py+++ b/ee/api/test/test_subscription.py@@ -56,6 +56,16 @@ from ee.tasks.subscriptions.teams_subscriptions import TEAMS_WEBHOOK_URL_ERROR,from ee.tasks.test.subscriptions.subscriptions_test_factory import create_subscriptionVALID_TEAMS_WEBHOOK_URL = "https://prod-25.westeurope.logic.azure.com:443/workflows/abc/triggers/manual/paths/invoke"+GALLERY_ON_PROMPT_ERROR = (+ "post_all_insights_in_main_message only applies to insight and dashboard subscriptions. This "+ "subscription has resource_type 'ai_prompt', so remove it from delivery_config. A prompt report "+ "already posts all its chart images in the main message."+)+GALLERY_FILES_WRITE_ERROR = (+ "post_all_insights_in_main_message requires the Slack files:write permission. Reconnect Slack to "+ "grant it, or remove the option from delivery_config to save the subscription now. Each delivery "+ "then posts the first image in the main message and the rest as threaded replies."+)VALID_AI_QUERY_PLAN = {"overall_intent": "Count events","steps": [@@ -778,7 +788,10 @@ class TestSubscriptionTemporal(APILicensedTest):def test_cannot_set_post_all_insights_in_main_message_on_email_subscription(self):response = self._create_subscription(delivery_config={"post_all_insights_in_main_message": True})assert response.status_code == status.HTTP_400_BAD_REQUEST- assert "only supported for Slack subscriptions" in response.json()["detail"]+ assert response.json()["detail"] == (+ "post_all_insights_in_main_message only applies to Slack subscriptions. "+ "This subscription delivers to email, so remove it from delivery_config."+ )def test_can_patch_delivery_config_on_slack_subscription(self):integration = Integration.objects.create(@@ -833,7 +846,7 @@ class TestSubscriptionTemporal(APILicensedTest):},)assert res.status_code == status.HTTP_400_BAD_REQUEST- assert "files:write" in str(res.json())+ assert res.json()["detail"] == GALLERY_FILES_WRITE_ERRORdef test_patch_post_all_in_main_requires_files_write_scope(self):integration = Integration.objects.create(@@ -849,7 +862,8 @@ class TestSubscriptionTemporal(APILicensedTest):{"delivery_config": {"post_all_insights_in_main_message": True}},)assert res.status_code == status.HTTP_400_BAD_REQUEST- assert "files:write" in str(res.json())+ # Exact text: an update must not be told to "create" the subscription.+ assert res.json()["detail"] == GALLERY_FILES_WRITE_ERRORdef test_patch_to_integration_without_files_write_rejects_persisted_gallery_flag(self):# Effective-config validation: moving an existing post_all_insights_in_main_message sub to an@@ -871,7 +885,15 @@ class TestSubscriptionTemporal(APILicensedTest):{"integration_id": without_scope.id},)assert res.status_code == status.HTTP_400_BAD_REQUEST- assert "files:write" in str(res.json())+ assert res.json()["detail"] == GALLERY_FILES_WRITE_ERROR++ def test_stored_ai_display_option_does_not_block_insight_edits(self):+ subscription = create_subscription(team=self.team, insight=self.insight, created_by=self.user)+ Subscription.objects.filter(id=subscription.id).update(delivery_config={"include_images": False})++ res = self.client.patch(f"/api/projects/{self.team.id}/subscriptions/{subscription.id}", {"enabled": False})++ assert res.status_code == status.HTTP_200_OK, res.json()def test_patch_slack_to_email_rejects_persisted_gallery_flag(self):# Effective-config validation across target_type: a Slack sub with the gallery flag PATCHed to@@ -890,7 +912,7 @@ class TestSubscriptionTemporal(APILicensedTest):{"target_type": "email", "target_value": "[email protected]"},)assert res.status_code == status.HTTP_400_BAD_REQUEST- assert "only supported for Slack" in str(res.json())+ assert "post_all_insights_in_main_message only applies to Slack subscriptions" in str(res.json())def test_post_all_in_main_allowed_with_files_write(self):integration = Integration.objects.create(@@ -4041,14 +4063,72 @@ class TestAISubscriptionAPI(APILicensedTest):assert patch_response.json()["delivery_config"] == expected_configassert Subscription.objects.get(id=subscription_id).delivery_config == expected_config- def test_patch_validates_the_merged_delivery_config(self, mock_is_cloud, mock_flag, mock_sync):+ @parameterized.expand(+ [+ ("unrelated_field", "files:write", {"enabled": False}),+ ("delivery_config_without_the_option", "files:write", {"delivery_config": {"include_images": False}}),+ ("slack_without_files_write", "channels:read", {"enabled": False}),+ ]+ )+ def test_stored_gallery_option_does_not_block_other_prompt_edits(+ self, mock_is_cloud, mock_flag, mock_sync, _name, extra_scope, patch_body+ ):self._enable_ai()self._mock_temporal(mock_sync)integration = Integration.objects.create(- team=self.team, kind="slack", config={"scope": "chat:write,files:write"}+ team=self.team, kind="slack", config={"scope": f"chat:write,{extra_scope}"})- without_files_write = Integration.objects.create(- team=self.team, kind="slack", config={"scope": "chat:write,channels:read"}+ create_response = self.client.post(+ f"/api/projects/{self.team.id}/subscriptions",+ self._make_ai_payload(+ target_type="slack",+ target_value="C1234|#general",+ integration_id=integration.id,+ ),+ )+ assert create_response.status_code == status.HTTP_201_CREATED, create_response.json()+ subscription_id = create_response.json()["id"]+ # Seeded directly because create rejects the option. Rows like this predate the rule, and+ # validating the stored value would leave them impossible to edit or even to disable.+ Subscription.objects.filter(id=subscription_id).update(+ delivery_config={"post_all_insights_in_main_message": True}+ )++ patch_response = self.client.patch(f"/api/projects/{self.team.id}/subscriptions/{subscription_id}", patch_body)++ assert patch_response.status_code == status.HTTP_200_OK, patch_response.json()++ @parameterized.expand(+ [+ ("email", "email", "[email protected]"),+ ("slack", "slack", "C1234|#general"),+ ]+ )+ def test_gallery_option_is_rejected_on_prompt_create(+ self, mock_is_cloud, mock_flag, mock_sync, _name, target_type, target_value+ ):+ self._enable_ai()+ self._mock_temporal(mock_sync)+ overrides: dict = {"target_type": target_type, "target_value": target_value}+ if target_type == "slack":+ # files:write present, so the permission rule cannot be what rejects the request.+ overrides["integration_id"] = Integration.objects.create(+ team=self.team, kind="slack", config={"scope": "chat:write,files:write"}+ ).id++ response = self.client.post(+ f"/api/projects/{self.team.id}/subscriptions",+ self._make_ai_payload(delivery_config={"post_all_insights_in_main_message": True}, **overrides),+ )++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert response.json()["detail"] == GALLERY_ON_PROMPT_ERROR++ def test_gallery_option_is_rejected_on_prompt_patch(self, mock_is_cloud, mock_flag, mock_sync):+ self._enable_ai()+ self._mock_temporal(mock_sync)+ integration = Integration.objects.create(+ team=self.team, kind="slack", config={"scope": "chat:write,files:write"})create_response = self.client.post(f"/api/projects/{self.team.id}/subscriptions",@@ -4056,33 +4136,63 @@ class TestAISubscriptionAPI(APILicensedTest):target_type="slack",target_value="C1234|#general",integration_id=integration.id,- delivery_config={"post_all_insights_in_main_message": True},),)assert create_response.status_code == status.HTTP_201_CREATED, create_response.json()patch_response = self.client.patch(f"/api/projects/{self.team.id}/subscriptions/{create_response.json()['id']}",- {- "integration_id": without_files_write.id,- "delivery_config": {"include_images": False},- },+ {"delivery_config": {"post_all_insights_in_main_message": True}},)assert patch_response.status_code == status.HTTP_400_BAD_REQUEST, patch_response.json()- assert "files:write" in str(patch_response.json())+ assert patch_response.json()["detail"] == GALLERY_ON_PROMPT_ERROR++ def test_gallery_option_is_accepted_as_false_on_a_prompt_subscription(self, mock_is_cloud, mock_flag, mock_sync):+ self._enable_ai()+ self._mock_temporal(mock_sync)+ response = self.client.post(+ f"/api/projects/{self.team.id}/subscriptions",+ self._make_ai_payload(delivery_config={"post_all_insights_in_main_message": False}),+ )++ assert response.status_code == status.HTTP_201_CREATED, response.json()++ @parameterized.expand(+ [+ (+ "single",+ {"include_images": False},+ "include_images only applies to prompt subscriptions. This subscription has "+ "resource_type 'insight', so remove it from delivery_config.",+ ),+ (+ "several",+ {"include_images": False, "include_feedback": True},+ "include_feedback and include_images only apply to prompt subscriptions. This "+ "subscription has resource_type 'insight', so remove them from delivery_config.",+ ),+ (+ "alongside_a_valid_option",+ {"include_manage_link": True, "post_all_insights_in_main_message": False},+ "include_manage_link only applies to prompt subscriptions. This subscription has "+ "resource_type 'insight', so remove it from delivery_config.",+ ),+ ]+ )def test_ai_delivery_display_flags_are_rejected_for_insight_subscriptions(- self, mock_is_cloud, mock_flag, mock_sync+ self, mock_is_cloud, mock_flag, mock_sync, _name, delivery_config, expected_detail):self._mock_temporal(mock_sync)payload = self._insight_payload()- payload["delivery_config"] = {"include_images": False}+ payload["delivery_config"] = delivery_configresponse = self.client.post(f"/api/projects/{self.team.id}/subscriptions", payload)assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert "only supported for prompt subscriptions" in str(response.json())+ # The valid option in the same delivery_config must not be named as the offender.+ assert response.json()["detail"] == expected_detailclass TestSubscriptionObjectAccessControl(APILicensedTest):diff --git a/products/subscriptions/frontend/components/Subscriptions/utils.test.ts b/products/subscriptions/frontend/components/Subscriptions/utils.test.tsindex 63a9661c9f7c..c400c502d71d 100644--- a/products/subscriptions/frontend/components/Subscriptions/utils.test.ts+++ b/products/subscriptions/frontend/components/Subscriptions/utils.test.ts@@ -296,6 +296,12 @@ describe('Slack gallery delivery config', () => {[slackIntegration(7, 'files:write')],false,],+ [+ 'removes the flag for a prompt subscription',+ subscription({ resource_type: 'ai_prompt' }),+ [slackIntegration(7, 'files:write')],+ false,+ ],['removes the flag when the loaded integration is missing', subscription({}), [], false],['preserves the flag while integrations are unresolved', subscription({}), null, true],])('%s', (_label, value, integrations, expected) => {diff --git a/products/subscriptions/frontend/components/Subscriptions/utils.tsx b/products/subscriptions/frontend/components/Subscriptions/utils.tsxindex 2939d95456c5..ea00f057a897 100644--- a/products/subscriptions/frontend/components/Subscriptions/utils.tsx+++ b/products/subscriptions/frontend/components/Subscriptions/utils.tsx@@ -333,6 +333,11 @@ export function coerceDeliveryConfigForScope(if (!deliveryConfig?.post_all_insights_in_main_message) {return deliveryConfig}+ // A prompt report always posts its charts in the main message, so the API rejects this option+ // and the form hides its toggle. Without this the stored flag has no control that can clear it.+ if (subscription.resource_type === SubscriptionResourceTypes.AiPrompt) {+ return { ...deliveryConfig, post_all_insights_in_main_message: false }+ }if (subscription.target_type !== 'slack') {return { ...deliveryConfig, post_all_insights_in_main_message: false }}diff --git a/products/subscriptions/frontend/generated/api.schemas.ts b/products/subscriptions/frontend/generated/api.schemas.tsindex 73a510df474a..afd6b5f26950 100644--- a/products/subscriptions/frontend/generated/api.schemas.ts+++ b/products/subscriptions/frontend/generated/api.schemas.ts@@ -203,15 +203,15 @@ export interface UserBasicApi {* Typed view over the Subscription.delivery_config JSON blob.*/export interface DeliveryConfigApi {- /** Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. */+ /** Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message. */post_all_insights_in_main_message?: boolean- /** AI prompt subscriptions only: include generated chart images. Defaults to true when omitted. */+ /** Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_images?: boolean- /** AI prompt subscriptions only: include report feedback links. Defaults to true when omitted. */+ /** Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_feedback?: boolean- /** AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. */+ /** Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_manage_link?: boolean- /** AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted. */+ /** Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_posthog_hint?: boolean}@@ -335,7 +335,7 @@ export interface SubscriptionApi {* @maxLength 500*/summary_prompt_guide?: string- /** Per-delivery rendering options. Each option documents which delivery targets it applies to. */+ /** Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options. */delivery_config?: DeliveryConfigApi}@@ -503,7 +503,7 @@ export interface SubscriptionWriteApi {* @maxLength 500*/summary_prompt_guide?: string- /** Per-delivery rendering options. Each option documents which delivery targets it applies to. */+ /** Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options. */delivery_config?: DeliveryConfigApi}@@ -662,7 +662,7 @@ export interface PatchedSubscriptionWriteApi {* @maxLength 500*/summary_prompt_guide?: string- /** Per-delivery rendering options. Each option documents which delivery targets it applies to. */+ /** Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options. */delivery_config?: DeliveryConfigApi}diff --git a/products/subscriptions/frontend/generated/api.zod.ts b/products/subscriptions/frontend/generated/api.zod.tsindex a6208697c67f..8319e1cc58a8 100644--- a/products/subscriptions/frontend/generated/api.zod.ts+++ b/products/subscriptions/frontend/generated/api.zod.ts@@ -210,36 +210,38 @@ export const SubscriptionsCreateBody = /* @__PURE__ */ zod.boolean().default(subscriptionsCreateBodyDeliveryConfigOnePostAllInsightsInMainMessageDefault).describe(- 'Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.'+ "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message."),include_images: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.'+ 'Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_feedback: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.'+ 'Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_manage_link: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.'+ 'Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_posthog_hint: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.'+ 'Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),}).describe('Typed view over the Subscription.delivery_config JSON blob.').optional()- .describe('Per-delivery rendering options. Each option documents which delivery targets it applies to.'),+ .describe(+ "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options."+ ),}).describe('Standard Subscription serializer.')@@ -444,36 +446,38 @@ export const SubscriptionsUpdateBody = /* @__PURE__ */ zod.boolean().default(subscriptionsUpdateBodyDeliveryConfigOnePostAllInsightsInMainMessageDefault).describe(- 'Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.'+ "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message."),include_images: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.'+ 'Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_feedback: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.'+ 'Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_manage_link: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.'+ 'Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_posthog_hint: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.'+ 'Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),}).describe('Typed view over the Subscription.delivery_config JSON blob.').optional()- .describe('Per-delivery rendering options. Each option documents which delivery targets it applies to.'),+ .describe(+ "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options."+ ),}).describe('Standard Subscription serializer.')@@ -683,35 +687,37 @@ export const SubscriptionsPartialUpdateBody = /* @__PURE__ */ zod.boolean().default(subscriptionsPartialUpdateBodyDeliveryConfigOnePostAllInsightsInMainMessageDefault).describe(- 'Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.'+ "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message."),include_images: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.'+ 'Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_feedback: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.'+ 'Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_manage_link: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.'+ 'Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_posthog_hint: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.'+ 'Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),}).describe('Typed view over the Subscription.delivery_config JSON blob.').optional()- .describe('Per-delivery rendering options. Each option documents which delivery targets it applies to.'),+ .describe(+ "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options."+ ),}).describe('Standard Subscription serializer.')diff --git a/products/subscriptions/mcp/tools.yaml b/products/subscriptions/mcp/tools.yamlindex 18bcebb969ba..40d721964f59 100644--- a/products/subscriptions/mcp/tools.yaml+++ b/products/subscriptions/mcp/tools.yaml@@ -47,9 +47,16 @@ tools:rejected.For insight and dashboard subscriptions you can attach an AI-generated summary to each delivery by setting- `summary_enabled: true` (optionally steered by `summary_prompt_guide`). This requires the organization to- have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the- create is rejected. Prompt subscriptions are themselves AI-generated, so these fields do not apply to them.+ `summary_enabled: true` (optionally steered by `summary_prompt_guide`, which must be 500 characters or+ fewer). This requires the organization to have approved AI data processing and to be within its+ active-summary cap and AI credit budget; otherwise the create is rejected. Prompt subscriptions are+ themselves AI-generated, so these fields do not apply to them.++ `delivery_config` is optional, and every option in it applies to one subscription kind or delivery target+ only. Omit the whole field unless the user asks for one of its options, because the create is rejected when+ an option does not apply. Each option's own description says where it applies. None of them control the AI+ summary on an insight or dashboard subscription, so use `summary_enabled` and `summary_prompt_guide` for+ that instead.IMPORTANT — when creating an insight (or dashboard) subscription, always ask the user whether to enable theAI-generated summary before creating it. Present it as their choice: they can turn it on (`summary_enabled:@@ -180,8 +187,14 @@ tools:webhook URL; the host returned by this API is not a valid replacement.For insight and dashboard subscriptions, toggle the per-delivery AI summary with `summary_enabled` and steer- it with `summary_prompt_guide`. Enabling a summary requires the organization to have approved AI data- processing and to be within its active-summary cap and AI credit budget; otherwise the update is rejected.+ it with `summary_prompt_guide` (500 characters or fewer). Enabling a summary requires the organization to+ have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the+ update is rejected.++ `delivery_config` options carry the same scope rules as on create, and the update is rejected when an option+ you send does not apply to this subscription. On a prompt subscription the object you send merges into the+ stored one instead of replacing it, so set an option to the value you want rather than expecting an omitted+ option to be cleared.exclude_params:- contexts- deleteddiff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex a2e1890f0179..ce3ba1f923ba 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -11119,7 +11119,7 @@"feature_flag": "streamlit-apps"},"subscriptions-create": {- "description": "Create a recurring subscription. The kind is inferred from which field you populate and returned as the read-only `resource_type`:\n(1) set `insight` — schedule periodic snapshots of one insight (`resource_type: \"insight\"`).\n(2) set `dashboard` and `dashboard_export_insights` (the subset of the dashboard's insights to include, max 10) — schedule periodic snapshots of one dashboard (`resource_type: \"dashboard\"`).\n(3) set `prompt` (≤4000 chars, with no insight or dashboard) — schedule a recurring LLM-generated report (`resource_type: \"ai_prompt\"`). Available on PostHog Cloud (self-hosted production is not eligible) once the organization has approved AI data processing and prompt subscriptions are enabled for it; otherwise create is rejected with a 400. Creating a prompt subscription also requires the `query:read` scope — the report runs LLM-generated HogQL over your data — so a `subscription:write`-only token is rejected for this kind.\nDelivery is set by `target_type` — `email`, `slack`, or `teams` (a Microsoft Teams webhook URL in `target_value`). A Teams webhook URL is only ever read back as its host. Creating a Teams subscription requires the full webhook URL in `target_value`.\nSet `start_date` to an ISO 8601 datetime. Its date anchors the recurrence and may be in the past. Deliveries run on half-hour cycles at :00 and :30. Other minute values are accepted for backward compatibility, but delivery happens during the next cycle instead of at that exact minute. For example, use a value ending in `T16:30:00Z` for the 16:30 delivery cycle.\nThe kind is fixed at create time — a PATCH that would change the populated relation to a different kind is rejected.\nFor insight and dashboard subscriptions you can attach an AI-generated summary to each delivery by setting `summary_enabled: true` (optionally steered by `summary_prompt_guide`). This requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the create is rejected. Prompt subscriptions are themselves AI-generated, so these fields do not apply to them.\nIMPORTANT — when creating an insight (or dashboard) subscription, always ask the user whether to enable the AI-generated summary before creating it. Present it as their choice: they can turn it on (`summary_enabled: true`) or leave it off, and if they turn it on, offer them the option to add a custom prompt to steer the summary (`summary_prompt_guide`). Do not enable the summary on your own without asking. (Prompt subscriptions are themselves AI-generated, so this does not apply to them.)",+ "description": "Create a recurring subscription. The kind is inferred from which field you populate and returned as the read-only `resource_type`:\n(1) set `insight` — schedule periodic snapshots of one insight (`resource_type: \"insight\"`).\n(2) set `dashboard` and `dashboard_export_insights` (the subset of the dashboard's insights to include, max 10) — schedule periodic snapshots of one dashboard (`resource_type: \"dashboard\"`).\n(3) set `prompt` (≤4000 chars, with no insight or dashboard) — schedule a recurring LLM-generated report (`resource_type: \"ai_prompt\"`). Available on PostHog Cloud (self-hosted production is not eligible) once the organization has approved AI data processing and prompt subscriptions are enabled for it; otherwise create is rejected with a 400. Creating a prompt subscription also requires the `query:read` scope — the report runs LLM-generated HogQL over your data — so a `subscription:write`-only token is rejected for this kind.\nDelivery is set by `target_type` — `email`, `slack`, or `teams` (a Microsoft Teams webhook URL in `target_value`). A Teams webhook URL is only ever read back as its host. Creating a Teams subscription requires the full webhook URL in `target_value`.\nSet `start_date` to an ISO 8601 datetime. Its date anchors the recurrence and may be in the past. Deliveries run on half-hour cycles at :00 and :30. Other minute values are accepted for backward compatibility, but delivery happens during the next cycle instead of at that exact minute. For example, use a value ending in `T16:30:00Z` for the 16:30 delivery cycle.\nThe kind is fixed at create time — a PATCH that would change the populated relation to a different kind is rejected.\nFor insight and dashboard subscriptions you can attach an AI-generated summary to each delivery by setting `summary_enabled: true` (optionally steered by `summary_prompt_guide`, which must be 500 characters or fewer). This requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the create is rejected. Prompt subscriptions are themselves AI-generated, so these fields do not apply to them.\n`delivery_config` is optional, and every option in it applies to one subscription kind or delivery target only. Omit the whole field unless the user asks for one of its options, because the create is rejected when an option does not apply. Each option's own description says where it applies. None of them control the AI summary on an insight or dashboard subscription, so use `summary_enabled` and `summary_prompt_guide` for that instead.\nIMPORTANT — when creating an insight (or dashboard) subscription, always ask the user whether to enable the AI-generated summary before creating it. Present it as their choice: they can turn it on (`summary_enabled: true`) or leave it off, and if they turn it on, offer them the option to add a custom prompt to steer the summary (`summary_prompt_guide`). Do not enable the summary on your own without asking. (Prompt subscriptions are themselves AI-generated, so this does not apply to them.)","category": "Subscriptions","feature": "subscriptions","summary": "Create subscription",@@ -11189,7 +11189,7 @@}},"subscriptions-partial-update": {- "description": "Update a subscription's mutable fields (title, target, schedule, the `prompt` for prompt subscriptions, `enabled`). The kind (`resource_type`) is fixed at create — a PATCH that would introduce another kind's field (e.g. a `prompt` on an insight sub) is rejected with 400. For prompt subs, re-enabling a previously auto-disabled sub requires both a valid `prompt` (already persisted or supplied in the PATCH body) and that the original creator is still an active user; otherwise it is rejected with 400. Editing or re-enabling a prompt subscription additionally requires the `query:read` scope. Use `subscriptions-delete` to soft-delete — `deleted` is not settable here.\nFor Microsoft Teams, omit `target_value` to keep the stored webhook URL. To replace it, send a full Teams webhook URL; the host returned by this API is not a valid replacement.\nFor insight and dashboard subscriptions, toggle the per-delivery AI summary with `summary_enabled` and steer it with `summary_prompt_guide`. Enabling a summary requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the update is rejected.",+ "description": "Update a subscription's mutable fields (title, target, schedule, the `prompt` for prompt subscriptions, `enabled`). The kind (`resource_type`) is fixed at create — a PATCH that would introduce another kind's field (e.g. a `prompt` on an insight sub) is rejected with 400. For prompt subs, re-enabling a previously auto-disabled sub requires both a valid `prompt` (already persisted or supplied in the PATCH body) and that the original creator is still an active user; otherwise it is rejected with 400. Editing or re-enabling a prompt subscription additionally requires the `query:read` scope. Use `subscriptions-delete` to soft-delete — `deleted` is not settable here.\nFor Microsoft Teams, omit `target_value` to keep the stored webhook URL. To replace it, send a full Teams webhook URL; the host returned by this API is not a valid replacement.\nFor insight and dashboard subscriptions, toggle the per-delivery AI summary with `summary_enabled` and steer it with `summary_prompt_guide` (500 characters or fewer). Enabling a summary requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the update is rejected.\n`delivery_config` options carry the same scope rules as on create, and the update is rejected when an option you send does not apply to this subscription. On a prompt subscription the object you send merges into the stored one instead of replacing it, so set an option to the value you want rather than expecting an omitted option to be cleared.","category": "Subscriptions","feature": "subscriptions","summary": "Update subscription",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 19b1343067d6..f82c24a87549 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -11691,7 +11691,7 @@"feature_flag": "streamlit-apps"},"subscriptions-create": {- "description": "Create a recurring subscription. The kind is inferred from which field you populate and returned as the read-only `resource_type`:\n(1) set `insight` — schedule periodic snapshots of one insight (`resource_type: \"insight\"`).\n(2) set `dashboard` and `dashboard_export_insights` (the subset of the dashboard's insights to include, max 10) — schedule periodic snapshots of one dashboard (`resource_type: \"dashboard\"`).\n(3) set `prompt` (≤4000 chars, with no insight or dashboard) — schedule a recurring LLM-generated report (`resource_type: \"ai_prompt\"`). Available on PostHog Cloud (self-hosted production is not eligible) once the organization has approved AI data processing and prompt subscriptions are enabled for it; otherwise create is rejected with a 400. Creating a prompt subscription also requires the `query:read` scope — the report runs LLM-generated HogQL over your data — so a `subscription:write`-only token is rejected for this kind.\nDelivery is set by `target_type` — `email`, `slack`, or `teams` (a Microsoft Teams webhook URL in `target_value`). A Teams webhook URL is only ever read back as its host. Creating a Teams subscription requires the full webhook URL in `target_value`.\nSet `start_date` to an ISO 8601 datetime. Its date anchors the recurrence and may be in the past. Deliveries run on half-hour cycles at :00 and :30. Other minute values are accepted for backward compatibility, but delivery happens during the next cycle instead of at that exact minute. For example, use a value ending in `T16:30:00Z` for the 16:30 delivery cycle.\nThe kind is fixed at create time — a PATCH that would change the populated relation to a different kind is rejected.\nFor insight and dashboard subscriptions you can attach an AI-generated summary to each delivery by setting `summary_enabled: true` (optionally steered by `summary_prompt_guide`). This requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the create is rejected. Prompt subscriptions are themselves AI-generated, so these fields do not apply to them.\nIMPORTANT — when creating an insight (or dashboard) subscription, always ask the user whether to enable the AI-generated summary before creating it. Present it as their choice: they can turn it on (`summary_enabled: true`) or leave it off, and if they turn it on, offer them the option to add a custom prompt to steer the summary (`summary_prompt_guide`). Do not enable the summary on your own without asking. (Prompt subscriptions are themselves AI-generated, so this does not apply to them.)",+ "description": "Create a recurring subscription. The kind is inferred from which field you populate and returned as the read-only `resource_type`:\n(1) set `insight` — schedule periodic snapshots of one insight (`resource_type: \"insight\"`).\n(2) set `dashboard` and `dashboard_export_insights` (the subset of the dashboard's insights to include, max 10) — schedule periodic snapshots of one dashboard (`resource_type: \"dashboard\"`).\n(3) set `prompt` (≤4000 chars, with no insight or dashboard) — schedule a recurring LLM-generated report (`resource_type: \"ai_prompt\"`). Available on PostHog Cloud (self-hosted production is not eligible) once the organization has approved AI data processing and prompt subscriptions are enabled for it; otherwise create is rejected with a 400. Creating a prompt subscription also requires the `query:read` scope — the report runs LLM-generated HogQL over your data — so a `subscription:write`-only token is rejected for this kind.\nDelivery is set by `target_type` — `email`, `slack`, or `teams` (a Microsoft Teams webhook URL in `target_value`). A Teams webhook URL is only ever read back as its host. Creating a Teams subscription requires the full webhook URL in `target_value`.\nSet `start_date` to an ISO 8601 datetime. Its date anchors the recurrence and may be in the past. Deliveries run on half-hour cycles at :00 and :30. Other minute values are accepted for backward compatibility, but delivery happens during the next cycle instead of at that exact minute. For example, use a value ending in `T16:30:00Z` for the 16:30 delivery cycle.\nThe kind is fixed at create time — a PATCH that would change the populated relation to a different kind is rejected.\nFor insight and dashboard subscriptions you can attach an AI-generated summary to each delivery by setting `summary_enabled: true` (optionally steered by `summary_prompt_guide`, which must be 500 characters or fewer). This requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the create is rejected. Prompt subscriptions are themselves AI-generated, so these fields do not apply to them.\n`delivery_config` is optional, and every option in it applies to one subscription kind or delivery target only. Omit the whole field unless the user asks for one of its options, because the create is rejected when an option does not apply. Each option's own description says where it applies. None of them control the AI summary on an insight or dashboard subscription, so use `summary_enabled` and `summary_prompt_guide` for that instead.\nIMPORTANT — when creating an insight (or dashboard) subscription, always ask the user whether to enable the AI-generated summary before creating it. Present it as their choice: they can turn it on (`summary_enabled: true`) or leave it off, and if they turn it on, offer them the option to add a custom prompt to steer the summary (`summary_prompt_guide`). Do not enable the summary on your own without asking. (Prompt subscriptions are themselves AI-generated, so this does not apply to them.)","category": "Subscriptions","feature": "subscriptions","summary": "Create subscription",@@ -11761,7 +11761,7 @@}},"subscriptions-partial-update": {- "description": "Update a subscription's mutable fields (title, target, schedule, the `prompt` for prompt subscriptions, `enabled`). The kind (`resource_type`) is fixed at create — a PATCH that would introduce another kind's field (e.g. a `prompt` on an insight sub) is rejected with 400. For prompt subs, re-enabling a previously auto-disabled sub requires both a valid `prompt` (already persisted or supplied in the PATCH body) and that the original creator is still an active user; otherwise it is rejected with 400. Editing or re-enabling a prompt subscription additionally requires the `query:read` scope. Use `subscriptions-delete` to soft-delete — `deleted` is not settable here.\nFor Microsoft Teams, omit `target_value` to keep the stored webhook URL. To replace it, send a full Teams webhook URL; the host returned by this API is not a valid replacement.\nFor insight and dashboard subscriptions, toggle the per-delivery AI summary with `summary_enabled` and steer it with `summary_prompt_guide`. Enabling a summary requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the update is rejected.",+ "description": "Update a subscription's mutable fields (title, target, schedule, the `prompt` for prompt subscriptions, `enabled`). The kind (`resource_type`) is fixed at create — a PATCH that would introduce another kind's field (e.g. a `prompt` on an insight sub) is rejected with 400. For prompt subs, re-enabling a previously auto-disabled sub requires both a valid `prompt` (already persisted or supplied in the PATCH body) and that the original creator is still an active user; otherwise it is rejected with 400. Editing or re-enabling a prompt subscription additionally requires the `query:read` scope. Use `subscriptions-delete` to soft-delete — `deleted` is not settable here.\nFor Microsoft Teams, omit `target_value` to keep the stored webhook URL. To replace it, send a full Teams webhook URL; the host returned by this API is not a valid replacement.\nFor insight and dashboard subscriptions, toggle the per-delivery AI summary with `summary_enabled` and steer it with `summary_prompt_guide` (500 characters or fewer). Enabling a summary requires the organization to have approved AI data processing and to be within its active-summary cap and AI credit budget; otherwise the update is rejected.\n`delivery_config` options carry the same scope rules as on create, and the update is rejected when an option you send does not apply to this subscription. On a prompt subscription the object you send merges into the stored one instead of replacing it, so set an option to the value you want rather than expecting an omitted option to be cleared.","category": "Subscriptions","feature": "subscriptions","summary": "Update subscription",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 39d55cabd4bb..3fb6977fdd70 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -29557,15 +29557,15 @@ export namespace Schemas {* Typed view over the Subscription.delivery_config JSON blob.*/export interface DeliveryConfig {- /** Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. */+ /** Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message. */post_all_insights_in_main_message?: boolean;- /** AI prompt subscriptions only: include generated chart images. Defaults to true when omitted. */+ /** Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_images?: boolean;- /** AI prompt subscriptions only: include report feedback links. Defaults to true when omitted. */+ /** Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_feedback?: boolean;- /** AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. */+ /** Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_manage_link?: boolean;- /** AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted. */+ /** Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that. */include_posthog_hint?: boolean;}@@ -62650,7 +62650,7 @@ export namespace Schemas {* @maxLength 500*/summary_prompt_guide?: string;- /** Per-delivery rendering options. Each option documents which delivery targets it applies to. */+ /** Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options. */delivery_config?: DeliveryConfig;}@@ -72308,7 +72308,7 @@ export namespace Schemas {* @maxLength 500*/summary_prompt_guide?: string;- /** Per-delivery rendering options. Each option documents which delivery targets it applies to. */+ /** Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options. */delivery_config?: DeliveryConfig;}@@ -90003,7 +90003,7 @@ export namespace Schemas {* @maxLength 500*/summary_prompt_guide?: string;- /** Per-delivery rendering options. Each option documents which delivery targets it applies to. */+ /** Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options. */delivery_config?: DeliveryConfig;}diff --git a/services/mcp/src/generated/subscriptions/api.ts b/services/mcp/src/generated/subscriptions/api.tsindex fc8eb011e6e9..0c8cdccade85 100644--- a/services/mcp/src/generated/subscriptions/api.ts+++ b/services/mcp/src/generated/subscriptions/api.ts@@ -225,36 +225,38 @@ export const SubscriptionsCreateBody = () => zod.boolean().default(subscriptionsCreateBodyDeliveryConfigOnePostAllInsightsInMainMessageDefault).describe(- 'Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.'+ "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message."),include_images: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.'+ 'Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_feedback: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.'+ 'Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_manage_link: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.'+ 'Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_posthog_hint: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.'+ 'Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),}).describe('Typed view over the Subscription.delivery_config JSON blob.').optional()- .describe('Per-delivery rendering options. Each option documents which delivery targets it applies to.'),+ .describe(+ "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options."+ ),}).describe('Standard Subscription serializer.')@@ -453,36 +455,38 @@ export const SubscriptionsPartialUpdateBody = () => zod.boolean().default(subscriptionsPartialUpdateBodyDeliveryConfigOnePostAllInsightsInMainMessageDefault).describe(- 'Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.'+ "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message."),include_images: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.'+ 'Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_feedback: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.'+ 'Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_manage_link: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.'+ 'Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),include_posthog_hint: zod.boolean().optional().describe(- 'AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.'+ 'Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.'),}).describe('Typed view over the Subscription.delivery_config JSON blob.').optional()- .describe('Per-delivery rendering options. Each option documents which delivery targets it applies to.'),+ .describe(+ "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options."+ ),}).describe('Standard Subscription serializer.')diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-create.jsonindex b9a922e919ba..03793374217f 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-create.json@@ -107,27 +107,27 @@"type": "array"},"delivery_config": {- "description": "Per-delivery rendering options. Each option documents which delivery targets it applies to.",+ "description": "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options.","properties": {"include_feedback": {- "description": "AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"include_images": {- "description": "AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"include_manage_link": {- "description": "AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"include_posthog_hint": {- "description": "AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"post_all_insights_in_main_message": {"default": false,- "description": "Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.",+ "description": "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message.","type": "boolean"}},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-partial-update.jsonindex fbf5d01669c9..0092968853e8 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-partial-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/subscriptions-partial-update.json@@ -106,27 +106,27 @@"type": "array"},"delivery_config": {- "description": "Per-delivery rendering options. Each option documents which delivery targets it applies to.",+ "description": "Per-delivery rendering options. Every option applies to one subscription kind or delivery target only, and each option's own description says where it applies and whether a mismatch is rejected or ignored. Omit this field unless the user asks for one of the options.","properties": {"include_feedback": {- "description": "AI prompt subscriptions only: include report feedback links. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include report feedback links. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"include_images": {- "description": "AI prompt subscriptions only: include generated chart images. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include generated chart images. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"include_manage_link": {- "description": "AI prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include a link to manage the subscription. Defaults to true when omitted. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"include_posthog_hint": {- "description": "AI prompt subscriptions only: include PostHog product guidance. Slack only. Email and Microsoft Teams reports do not include it. Defaults to true when omitted.",+ "description": "Prompt subscriptions only: include PostHog product guidance. Defaults to true when omitted. Only a Slack report renders the guidance. Email and Microsoft Teams reports leave it out and accept the option without an error, unlike post_all_insights_in_main_message. The request is rejected when the subscription sets insight or dashboard instead of prompt. It does not control the AI summary on an insight or dashboard subscription: use summary_enabled and summary_prompt_guide for that.","type": "boolean"},"post_all_insights_in_main_message": {"default": false,- "description": "Slack only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false.",+ "description": "Slack insight and dashboard subscriptions only: when true, upload all insight images together in the main Slack message instead of posting the first image in the main message and the rest as threaded replies. Defaults to false. The request is rejected when target_type is not 'slack', when the subscription sets prompt instead of insight or dashboard, or when the Slack integration does not hold the files:write permission. Omit it unless the user asks for one combined message.","type": "boolean"}},