: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
feat(messaging): give recipient preference writes their own scope (#128116)
Michael Reichenbach22c17b52dd08
diff --git a/frontend/src/lib/oauthScopes.generated.ts b/frontend/src/lib/oauthScopes.generated.tsindex 961c6ac7ee4b..410147d3a305 100644--- a/frontend/src/lib/oauthScopes.generated.ts+++ b/frontend/src/lib/oauthScopes.generated.ts@@ -252,6 +252,8 @@ export type OAuthScope = (typeof OAUTH_SCOPES_SUPPORTED)[number]export const OAUTH_SCOPES_HIDDEN = ['batch_import_support:read','batch_import_support:write',+ 'messaging_preference:read',+ 'messaging_preference:write','query_performance:read','query_performance:write','wizard_run:read',@@ -263,4 +265,7 @@ export const OAUTH_SCOPES_HIDDEN = [// A new scope object mapped to the legacy one it split off (mirrors LEGACY_SCOPE_FALLBACKS// in posthog/scopes.py). While old tokens carry only the legacy scope, a held// `<legacy>:<action>` satisfies a required `<new>:<action>`.-export const LEGACY_SCOPE_FALLBACKS: ReadonlyMap<string, string> = new Map([['inbox', 'task']])+export const LEGACY_SCOPE_FALLBACKS: ReadonlyMap<string, string> = new Map([+ ['inbox', 'task'],+ ['messaging_preference', 'hog_flow'],+])diff --git a/frontend/src/lib/scopes.tsx b/frontend/src/lib/scopes.tsxindex 71cebbfc795f..72ee6c8153c3 100644--- a/frontend/src/lib/scopes.tsx+++ b/frontend/src/lib/scopes.tsx@@ -390,6 +390,7 @@ export const PROJECT_SECRET_API_KEY_ALLOWED_API_SCOPE_ACTION = ['session_recording:read','hog_flow:read','hog_flow:write',+ 'messaging_preference:write',] as constexport type ProjectSecretAPIKeyAllowedScope = (typeof PROJECT_SECRET_API_KEY_ALLOWED_API_SCOPE_ACTION)[number]@@ -504,6 +505,7 @@ export const PROJECT_SECRET_API_KEY_SCOPE_PRESETS: ProjectSecretAPIKeyScopePrese{ value: 'endpoint_execution', label: 'Endpoint execution', scopes: ['endpoint:read'] },{ value: 'local_evaluation', label: 'Local feature flag evaluation', scopes: ['feature_flag:read'] },{ value: 'llm_gateway', label: 'AI gateway access', scopes: ['llm_gateway:read'] },+ { value: 'recipient_preferences', label: 'Set recipient preferences', scopes: ['messaging_preference:write'] },]// The product areas that the scope pickers use to group objects, in display order. Each scope objectdiff --git a/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsx b/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsxindex d69596b27442..d24fa36644e4 100644--- a/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsx+++ b/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.test.tsx@@ -85,6 +85,14 @@ describe('<ProjectSecretAPIKeys />', () => {})+ it('names the recipient preference row and says it cannot send email', () => {+ expect(logic.values.filteredScopes.find(({ key }) => key === 'messaging_preference')).toMatchObject({+ label: 'Recipient preference',+ info: expect.stringContaining("can't send email"),+ disabledActions: ['read'],+ })+ })+it.each([{ dialog: 'created', show: (key: ProjectSecretAPIKeyApi) => logic.actions.createKeySuccess(key) },{ dialog: 'rolled', show: (key: ProjectSecretAPIKeyApi) => logic.actions.showRollKeySuccessDialog(key) },diff --git a/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.tsx b/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.tsxindex ea59e3917ec0..84c27d200cfc 100644--- a/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.tsx+++ b/frontend/src/scenes/settings/project/ProjectSecretAPIKeys.tsx@@ -97,7 +97,7 @@ function EditKeyModal(): JSX.Element {{filteredScopes.length === 0 ? (<div className="text-muted text-sm py-2">No scopes match "{searchTerm}"</div>) : (- filteredScopes.map(({ key, label, disabledActions }) => {+ filteredScopes.map(({ key, label, info, disabledActions }) => {const disabledReason = (action: 'read' | 'write'): string | undefined =>disabledActions?.includes(action)? 'Not available for project secret API keys'@@ -108,6 +108,7 @@ function EditKeyModal(): JSX.Element {row={{key,label,+ info,value: (formScopeRadioValues[key] ?? 'none') as ScopeAccessLevel,disabledReasons: {read: disabledReason('read'),diff --git a/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsx b/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsxindex 14ca09b8ce73..0a8a7cf11b9f 100644--- a/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsx+++ b/frontend/src/scenes/settings/project/projectSecretAPIKeysLogic.tsx@@ -3,6 +3,7 @@ import { forms } from 'kea-forms'import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from 'kea-forms'import { loaders } from 'kea-loaders'import { router } from 'kea-router'+import type { JSX } from 'react'import { LemonDialog } from '@posthog/lemon-ui'@@ -33,9 +34,14 @@ export const MAX_PROJECT_API_KEYS_PER_PROJECT = 50const GATEWAY_SCOPE = 'llm_gateway:read'-// PAKs label this scope "LLM gateway"; here it is the AI gateway service credential.-const PROJECT_SECRET_SCOPE_OBJECT_NAMES: Record<string, string> = {- llm_gateway: 'AI gateway',+// Rows that differ from API_SCOPES here. PAKs label llm_gateway "LLM gateway", but here it is the AI gateway+// service credential. messaging_preference is OAuth-hidden, so it has no API_SCOPES row and only this picker offers it.+const PROJECT_SECRET_SCOPE_ROWS: Record<string, { label: string; info?: string }> = {+ llm_gateway: { label: 'AI gateway' },+ messaging_preference: {+ label: 'Recipient preference',+ info: "Opt email recipients in or out of your message topics. This scope can't send email.",+ },}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -55,6 +61,7 @@ export interface projectSecretAPIKeysLogicValues {editingKeyValidationErrors: DeepPartialMap<EditingProjectKeyFormValues, ValidationErrorType>filteredScopes: {disabledActions: APIScopeAction[]+ info: string | JSX.Element | undefinedkey: stringlabel: string}[]@@ -207,6 +214,7 @@ export interface projectSecretAPIKeysLogicMeta {user: UserType | null) => {disabledActions: APIScopeAction[]+ info: string | JSX.Element | undefinedkey: stringlabel: string}[]@@ -383,7 +391,12 @@ export const projectSecretAPIKeysLogic = kea<projectSecretAPIKeysLogicType>([(searchTerm: string,user: UserType | null- ): { key: string; label: string; disabledActions: APIScopeAction[] }[] => {+ ): {+ key: string+ label: string+ info: string | JSX.Element | undefined+ disabledActions: APIScopeAction[]+ }[] => {const allActions: APIScopeAction[] = ['read', 'write']// llm_gateway:read is staff-only, mirroring the backend.const allowedScopeActions: string[] = [...PROJECT_SECRET_API_KEY_ALLOWED_API_SCOPE_ACTION]@@ -398,14 +411,16 @@ export const projectSecretAPIKeysLogic = kea<projectSecretAPIKeysLogicType>([}allowedByKey.get(key)!.add(action)}- const scopes = Array.from(allowedByKey.entries()).map(([key, allowed]) => ({- key,- label:- PROJECT_SECRET_SCOPE_OBJECT_NAMES[key] ??- API_SCOPES.find((scope) => scope.key === key)?.objectName ??- capitalizeFirstLetter(key.replace(/_/g, ' ')),- disabledActions: allActions.filter((a) => !allowed.has(a)),- }))+ const scopes = Array.from(allowedByKey.entries()).map(([key, allowed]) => {+ const apiScope = API_SCOPES.find((scope) => scope.key === key)+ const row = PROJECT_SECRET_SCOPE_ROWS[key]+ return {+ key,+ label: row?.label ?? apiScope?.objectName ?? capitalizeFirstLetter(key.replace(/_/g, ' ')),+ info: row?.info ?? apiScope?.info,+ disabledActions: allActions.filter((a) => !allowed.has(a)),+ }+ })return scopes.filter((scope) => scopeMatchesSearch(scope, searchTerm))},],diff --git a/posthog/permissions.py b/posthog/permissions.pyindex cc6568cda9e3..73416338a6fb 100644--- a/posthog/permissions.py+++ b/posthog/permissions.py@@ -754,6 +754,15 @@ def get_authenticator_scopes(authenticator) -> list[str] | None:return None+def legacy_scope_object_used(request: Request, required_scope: str) -> str | None:+ """The legacy scope object that satisfied `required_scope` through LEGACY_SCOPE_FALLBACKS, or+ None when the request's token holds `required_scope` itself."""+ held = get_authenticator_scopes(getattr(request, "successful_authenticator", None)) or []+ covered = scopes_covered_by_legacy_fallback(held, scopes_not_covered(held, [required_scope]))+ legacy_scope = covered.get(required_scope)+ return legacy_scope.split(":", 1)[0] if legacy_scope else None++def scopes_caller_lacks(request: Request | None, scopes: Iterable[str]) -> list[str]:"""The given scopes that the request's token does not cover, sorted. Empty for session auth and`*` keys, which carry the user's full authority."""diff --git a/posthog/scopes.py b/posthog/scopes.pyindex 44b600b22306..2bb759b4b6f9 100644--- a/posthog/scopes.py+++ b/posthog/scopes.py@@ -98,6 +98,7 @@ APIScopeObject = Literal["mcp_builtin_agent","mcp_analytics","mcp_registry",+ "messaging_preference","metrics","notebook","offline_evaluation_ingestion",@@ -237,6 +238,8 @@ OAUTH_HIDDEN_SCOPE_OBJECTS: frozenset[APIScopeObject] = frozenset(# `is_staff`. Distinct from the public `batch_import` object on purpose: that one is# OAuth-advertised, and a customer-grantable scope must never name a staff surface."batch_import_support",+ # Its only route accepts project secret API keys alone, so only that key picker offers it.+ "messaging_preference",})@@ -281,6 +284,7 @@ PROJECT_SECRET_API_KEY_ALLOWED_API_SCOPE_ACTION: list[tuple[APIScopeObject, APIS# Every other hog_flow route stays PSAK-denied, because no other hog_flow viewset lists PSAK actions.("hog_flow", "read"),("hog_flow", "write"),+ ("messaging_preference", "write"),]# Server-side scope assignment string-set constants (see RFC: server-side scope@@ -488,7 +492,11 @@ def scopes_not_covered(held_scopes: Iterable[str], required_scopes: Iterable[str# APIScopePermission applies this and records each use, so the entry can go when no caller needs it.# Project secret API key issuance does not apply it: a key must not get a scope on the strength of a# legacy one. `hogli build:projections` copies this map to the MCP server, which applies it in `hasScope`.-LEGACY_SCOPE_FALLBACKS: dict[str, str] = {"inbox": "task"}+LEGACY_SCOPE_FALLBACKS: dict[str, str] = {+ "inbox": "task",+ # Permanent: `hog_flow:write` stays a supported way to set recipient preferences. Keep it on low use.+ "messaging_preference": "hog_flow",+}def scopes_covered_by_legacy_fallback(held_scopes: Iterable[str], missing_scopes: Iterable[str]) -> dict[str, str]:diff --git a/products/access_control/frontend/generated/api.schemas.ts b/products/access_control/frontend/generated/api.schemas.tsindex 0ecbe05a72c9..e8268af3e9bc 100644--- a/products/access_control/frontend/generated/api.schemas.ts+++ b/products/access_control/frontend/generated/api.schemas.ts@@ -115,6 +115,7 @@ export const ResolvedAccessSourceSubjectEnumApi = {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -237,6 +238,7 @@ export const ScopeObjectEnumApi = {MarketingAnalytics: 'marketing_analytics',McpAnalytics: 'mcp_analytics',McpRegistry: 'mcp_registry',+ MessagingPreference: 'messaging_preference',Metrics: 'metrics',Notebook: 'notebook',OfflineEvaluationIngestion: 'offline_evaluation_ingestion',@@ -382,6 +384,7 @@ export interface ProjectAccessSourceApi {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -547,6 +550,7 @@ export interface AccessControlObjectRuleApi {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -940,6 +944,7 @@ export interface AccessControlObjectRuleResourceApi {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -1228,6 +1233,7 @@ export interface ResolvedAccessApi {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestiondiff --git a/products/messaging/backend/presentation/views/topic_preferences.py b/products/messaging/backend/presentation/views/topic_preferences.pyindex 8d8e9e9e7c83..cff949aa7693 100644--- a/products/messaging/backend/presentation/views/topic_preferences.py+++ b/products/messaging/backend/presentation/views/topic_preferences.py@@ -11,7 +11,7 @@ from posthog.api.mixins import ValidatedRequest, validated_requestfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.auth import ProjectSecretAPIKeyAuthenticationfrom posthog.event_usage import report_user_action-from posthog.permissions import is_authenticated_via_project_secret_api_key+from posthog.permissions import is_authenticated_via_project_secret_api_key, legacy_scope_object_usedfrom posthog.rate_limit import PersonalOrProjectSecretApiKeyRateThrottle, ProjectSecretApiKeyTeamRateThrottlefrom products.messaging.backend.facade.preferences import TopicsNotFound, set_preferences@@ -83,7 +83,8 @@ class TopicPreferencesTeamSustainedThrottle(ProjectSecretApiKeyTeamRateThrottle)class TopicPreferencesViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):- scope_object = "hog_flow"+ # LEGACY_SCOPE_FALLBACKS lets `hog_flow:write` satisfy this scope too, with no end date.+ scope_object = "messaging_preference"permission_classes = [IsAuthenticated]authentication_classes = [ProjectSecretAPIKeyAuthentication]psak_allowed_actions = ["create"]@@ -113,8 +114,9 @@ class TopicPreferencesViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"Opt one recipient out of topics, or back in, in one call. `all_marketing` applies first, then each ""topic in order, and the whole change is saved at once. The same change twice ends the same, but a retry ""that lands after a newer change undoes that change. Workflows sends skip a marketing topic the "- "recipient opted out of. Needs a project secret API key with the `hog_flow:write` scope, which can also "- "send transactional email."+ "recipient opted out of. Needs a project secret API key with the `messaging_preference:write` scope, "+ "which cannot send email. A key with `hog_flow:write` also works, but that scope can send transactional "+ "email too."),)def create(self, request: ValidatedRequest, *args: Any, **kwargs: Any) -> Response:@@ -145,9 +147,13 @@ class TopicPreferencesViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"outcome": outcome,"topic_count": len(data.get("topics") or {}),"sets_all_marketing": "all_marketing" in data,+ "authorized_by": self._authorized_by(request),},team=self.team,organization=self.organization,)except Exception as e:logger.warning("Failed to capture messaging preferences api event", error=str(e))++ def _authorized_by(self, request: ValidatedRequest) -> str:+ return legacy_scope_object_used(request, f"{self.scope_object}:write") or self.scope_objectdiff --git a/products/messaging/backend/tests/api/test_topic_preferences.py b/products/messaging/backend/tests/api/test_topic_preferences.pyindex 7b0bfd670eaf..07b01fe7e118 100644--- a/products/messaging/backend/tests/api/test_topic_preferences.py+++ b/products/messaging/backend/tests/api/test_topic_preferences.py@@ -33,7 +33,7 @@ class TestTopicPreferences(APIBaseTest):self.product_updates = MessageCategory.objects.create(team=self.team, key="product-updates", name="Product updates")- self.psak = self._psak_client(["hog_flow:write"])+ self.psak = self._psak_client(["messaging_preference:write"])def _psak_client(self, scopes: list[str], team: Any = None) -> APIClient:raw_token = generate_random_token_secret()@@ -164,11 +164,36 @@ class TestTopicPreferences(APIBaseTest):@parameterized.expand([- ("read_only_key", ["hog_flow:read"]),+ ("preference_scope", ["messaging_preference:write"], "messaging_preference"),+ ("workflow_scope", ["hog_flow:write"], "hog_flow"),+ ("both_scopes", ["hog_flow:write", "messaging_preference:write"], "messaging_preference"),+ ]+ )+ def test_accepts_either_write_scope_and_reports_which_one_authorized(+ self, _flag: MagicMock, _name: str, scopes: list[str], authorized_by: str+ ) -> None:+ with patch("posthog.event_usage.posthoganalytics.capture") as capture:+ response = self._set(+ {"identifier": "[email protected]", "topics": {"newsletter": False}}, self._psak_client(scopes)+ )++ assert response.status_code == status.HTTP_200_OK, response.json()+ assert self._stored() == {str(self.newsletter.id): OPTED_OUT}+ reports = [+ call.kwargs["properties"]+ for call in capture.call_args_list+ if call.kwargs["event"] == "messaging preferences api set"+ ]+ assert [report["authorized_by"] for report in reports] == [authorized_by]++ @parameterized.expand(+ [+ ("read_only_workflow_key", ["hog_flow:read"]),+ ("read_only_preference_key", ["messaging_preference:read"]),("unrelated_scope", ["feature_flag:read"]),])- def test_refuses_a_project_secret_key_without_hog_flow_write(+ def test_refuses_a_project_secret_key_without_a_write_scope(self, _flag: MagicMock, _name: str, scopes: list[str]) -> None:response = self._set({"identifier": "[email protected]", "all_marketing": False}, self._psak_client(scopes))@@ -181,7 +206,7 @@ class TestTopicPreferences(APIBaseTest):response = self._set({"identifier": "[email protected]", "all_marketing": False},- self._psak_client(["hog_flow:write"], team=other_team),+ self._psak_client(["messaging_preference:write"], team=other_team),)assert response.status_code == status.HTTP_403_FORBIDDEN, response.json()diff --git a/products/messaging/backend/tests/api/test_transactional_email.py b/products/messaging/backend/tests/api/test_transactional_email.pyindex 0c1618de3de5..9aa3d4780166 100644--- a/products/messaging/backend/tests/api/test_transactional_email.py+++ b/products/messaging/backend/tests/api/test_transactional_email.py@@ -160,8 +160,16 @@ class TestTransactionalEmail(APIBaseTest):[("send_with_write_scope", "post", "send/", ["hog_flow:write"], status.HTTP_202_ACCEPTED),("send_with_read_scope", "post", "send/", ["hog_flow:read"], status.HTTP_403_FORBIDDEN),+ ("send_with_preference_scope", "post", "send/", ["messaging_preference:write"], status.HTTP_403_FORBIDDEN),("send_email_with_write_scope", "post", "send_email", ["hog_flow:write"], status.HTTP_202_ACCEPTED),("send_email_with_read_scope", "post", "send_email", ["hog_flow:read"], status.HTTP_403_FORBIDDEN),+ (+ "send_email_with_preference_scope",+ "post",+ "send_email",+ ["messaging_preference:write"],+ status.HTTP_403_FORBIDDEN,+ ),("retrieve_is_not_a_psak_action", "get", "", ["hog_flow:write"], status.HTTP_403_FORBIDDEN),("make_transactional_is_not_a_psak_action",diff --git a/products/messaging/backend/tests/api/test_transactional_email_status.py b/products/messaging/backend/tests/api/test_transactional_email_status.pyindex 44955c8b4316..194280995d63 100644--- a/products/messaging/backend/tests/api/test_transactional_email_status.py+++ b/products/messaging/backend/tests/api/test_transactional_email_status.py@@ -157,6 +157,7 @@ class TestTransactionalEmailStatus(ClickhouseTestMixin, APIBaseTest):[("read_scope", ["hog_flow:read"], status.HTTP_200_OK),("no_workflow_scope", ["feature_flag:read"], status.HTTP_403_FORBIDDEN),+ ("preference_scope", ["messaging_preference:write"], status.HTTP_403_FORBIDDEN),])def test_project_secret_api_key_needs_the_read_scope(self, _flag, _name, scopes, expected_status):diff --git a/products/messaging/frontend/generated/api.ts b/products/messaging/frontend/generated/api.tsindex bc9ad372bd82..a1cab217b7d3 100644--- a/products/messaging/frontend/generated/api.ts+++ b/products/messaging/frontend/generated/api.ts@@ -88,7 +88,7 @@ export const getMessagingPreferencesCreateUrl = (projectId: string) => {}/**- * Opt one recipient out of topics, or back in, in one call. `all_marketing` applies first, then each topic in order, and the whole change is saved at once. The same change twice ends the same, but a retry that lands after a newer change undoes that change. Workflows sends skip a marketing topic the recipient opted out of. Needs a project secret API key with the `hog_flow:write` scope, which can also send transactional email.+ * Opt one recipient out of topics, or back in, in one call. `all_marketing` applies first, then each topic in order, and the whole change is saved at once. The same change twice ends the same, but a retry that lands after a newer change undoes that change. Workflows sends skip a marketing topic the recipient opted out of. Needs a project secret API key with the `messaging_preference:write` scope, which cannot send email. A key with `hog_flow:write` also works, but that scope can send transactional email too.* @summary Set a recipient's topic preferences*/export const messagingPreferencesCreate = async (diff --git a/products/messaging/frontend/generated/api.zod.ts b/products/messaging/frontend/generated/api.zod.tsindex 29d6189042c0..9afc4f67e4ab 100644--- a/products/messaging/frontend/generated/api.zod.ts+++ b/products/messaging/frontend/generated/api.zod.ts@@ -10,7 +10,7 @@import * as zod from 'zod'/**- * Opt one recipient out of topics, or back in, in one call. `all_marketing` applies first, then each topic in order, and the whole change is saved at once. The same change twice ends the same, but a retry that lands after a newer change undoes that change. Workflows sends skip a marketing topic the recipient opted out of. Needs a project secret API key with the `hog_flow:write` scope, which can also send transactional email.+ * Opt one recipient out of topics, or back in, in one call. `all_marketing` applies first, then each topic in order, and the whole change is saved at once. The same change twice ends the same, but a retry that lands after a newer change undoes that change. Workflows sends skip a marketing topic the recipient opted out of. Needs a project secret API key with the `messaging_preference:write` scope, which cannot send email. A key with `hog_flow:write` also works, but that scope can send transactional email too.* @summary Set a recipient's topic preferences*/export const messagingPreferencesCreateBodyIdentifierMax = 512diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 32b8c57f77b4..f411a4672966 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -786,6 +786,7 @@ export namespace Schemas {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -909,6 +910,7 @@ export namespace Schemas {MarketingAnalytics: 'marketing_analytics',McpAnalytics: 'mcp_analytics',McpRegistry: 'mcp_registry',+ MessagingPreference: 'messaging_preference',Metrics: 'metrics',Notebook: 'notebook',OfflineEvaluationIngestion: 'offline_evaluation_ingestion',@@ -1032,6 +1034,7 @@ export namespace Schemas {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -1278,6 +1281,7 @@ export namespace Schemas {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -1690,6 +1694,7 @@ export namespace Schemas {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestion@@ -64786,6 +64791,7 @@ export namespace Schemas {* * `marketing_analytics` - marketing_analytics* * `mcp_analytics` - mcp_analytics* * `mcp_registry` - mcp_registry+ * * `messaging_preference` - messaging_preference* * `metrics` - metrics* * `notebook` - notebook* * `offline_evaluation_ingestion` - offline_evaluation_ingestiondiff --git a/services/mcp/src/lib/oauth-scopes.generated.ts b/services/mcp/src/lib/oauth-scopes.generated.tsindex 961c6ac7ee4b..410147d3a305 100644--- a/services/mcp/src/lib/oauth-scopes.generated.ts+++ b/services/mcp/src/lib/oauth-scopes.generated.ts@@ -252,6 +252,8 @@ export type OAuthScope = (typeof OAUTH_SCOPES_SUPPORTED)[number]export const OAUTH_SCOPES_HIDDEN = ['batch_import_support:read','batch_import_support:write',+ 'messaging_preference:read',+ 'messaging_preference:write','query_performance:read','query_performance:write','wizard_run:read',@@ -263,4 +265,7 @@ export const OAUTH_SCOPES_HIDDEN = [// A new scope object mapped to the legacy one it split off (mirrors LEGACY_SCOPE_FALLBACKS// in posthog/scopes.py). While old tokens carry only the legacy scope, a held// `<legacy>:<action>` satisfies a required `<new>:<action>`.-export const LEGACY_SCOPE_FALLBACKS: ReadonlyMap<string, string> = new Map([['inbox', 'task']])+export const LEGACY_SCOPE_FALLBACKS: ReadonlyMap<string, string> = new Map([+ ['inbox', 'task'],+ ['messaging_preference', 'hog_flow'],+])