: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(customer-analytics): allow personal keys on bulk account reads (#102124)
Abhischek14d7955c74da
diff --git a/docs/internal/customer-analytics-external-api.md b/docs/internal/customer-analytics-external-api.mdnew file mode 100644index 000000000000..ed3c90ffd43f--- /dev/null+++ b/docs/internal/customer-analytics-external-api.md@@ -0,0 +1,58 @@+# Customer analytics bulk account API++`GET /api/customer_analytics/external/accounts` returns accounts and their active relationship assignments.+Use a project secret API key or a personal API key with `account:read` scope.+Send the key in the `Authorization: Bearer <key>` header.+The endpoint does not accept the public project token or the legacy team secret token.+Invalid personal and project secret keys share an IP rate limit.+Requests over this limit return HTTP 429.++## Personal API keys++Personal keys require the `project_id` query parameter:++```http+GET /api/customer_analytics/external/accounts?project_id=<project_id>+Authorization: Bearer <personal_api_key>+```++The endpoint accepts current `phx_` keys and legacy personal keys without a prefix.+It uses the standard personal-key parser, which also accepts `personal_api_key` in the request body or query string.++The key must permit access to the selected project and organization.+The key owner must have project access and permission to read accounts.+Creating an account or receiving an individual account grant does not override a resource-level denial.+Organization security rules also apply.+The response includes only accounts the key owner can access.+Account access filters apply before pagination.+The endpoint does not use the key owner's currently selected project.+An unknown project ID returns HTTP 404.+An existing project that the key cannot access returns HTTP 403.+Personal-key permission errors use the standard `type`, `code`, `detail`, and `attr` fields.+Other authentication and scope errors can use the `error` field.+The API schema describes both formats for HTTP 401 and 403.++## Project secret API keys++Project secret keys (`phs_...`) use the project bound to the key.+The `project_id` parameter is optional for these keys.+If supplied, it must match the key's project.+These service keys retain project-wide account access within their scopes.++## Pagination and assignments++The response contains `results` and `next_cursor`.+Pass a non-null `next_cursor` as the next request's `cursor` parameter.+Keep `project_id` and all filters the same for every page.+The default and maximum page size is 100.++Each account's `relationships` object maps relationship names to arrays of assigned users.+Each assignment contains `user_id`, `email`, and `name`.+Roles without active assignments are omitted.+Use `external_id` to match accounts to external records.++Ignored accounts are excluded by default.+Use `include_ignored=true` to include them or `assigned_only=true` to return accounts with active assignments.+Use `managed_only=true` to return accounts with at least one controlled relationship.+This filter includes ignored accounts and cleared roles, and personal-key access rules still apply.+An account absent from the response can be filtered or inaccessible, so absence alone does not mean its ownership was cleared.diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.pyindex 278837362ddd..738de27ce2eb 100644--- a/products/customer_analytics/backend/facade/api.py+++ b/products/customer_analytics/backend/facade/api.py@@ -608,6 +608,7 @@ def list_external_accounts(assigned_only: bool = False,include_ignored: bool = False,managed_only: bool = False,+ user_access_control: UserAccessControl | None = None,) -> contracts.ExternalAccountListPage:"""Page through the team's accounts for the external API, ordered by id.@@ -629,7 +630,12 @@ def list_external_accounts(user__isnull=False,user__organization_membership__organization_id=organization_id,)- queryset = Account.objects.for_team(team_id).filter(external_id__isnull=False).exclude(external_id="")+ queryset: QuerySet[Account] = (+ _accounts_queryset(team_id, user_access_control)+ if user_access_control is not None+ else Account.objects.for_team(team_id)+ )+ queryset = queryset.filter(external_id__isnull=False).exclude(external_id="")if not include_ignored and not managed_only:queryset = queryset.filter(ignored_at__isnull=True)queryset = queryset.order_by("id")diff --git a/products/customer_analytics/backend/presentation/views/external.py b/products/customer_analytics/backend/presentation/views/external.pyindex efd40ebb698a..4835f9338870 100644--- a/products/customer_analytics/backend/presentation/views/external.py+++ b/products/customer_analytics/backend/presentation/views/external.py@@ -4,7 +4,7 @@ External API endpoints for the Customer analytics product.The single-account endpoints are used by the CDP worker for workflow actions andauthenticate via the team secret API token passed as a Bearer token in theAuthorization header. The bulk account list instead authenticates via a project-secret API key carrying the ``account:read`` scope, because the team token is+secret API key or personal API key carrying the ``account:read`` scope, because the team token isreadable by every project member and must not unlock a team-wide account export.The single-account GET accepts either credential; its writes stay team-token only.@@ -32,16 +32,19 @@ from django.http import HttpRequestimport structlogimport posthoganalyticsfrom drf_spectacular.types import OpenApiTypes-from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema+from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, PolymorphicProxySerializer, extend_schemafrom rest_framework import serializers, status+from rest_framework.exceptions import AuthenticationFailedfrom rest_framework.permissions import AllowAnyfrom rest_framework.request import Requestfrom rest_framework.response import Responsefrom rest_framework.throttling import SimpleRateThrottlefrom rest_framework.views import APIView+from rest_framework.viewsets import GenericViewSet+from posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.api.utils import ErrorResponseSerializer-from posthog.auth import ProjectSecretAPIKeyAuthentication+from posthog.auth import PersonalAPIKeyAuthentication, ProjectSecretAPIKeyAuthenticationfrom posthog.models import Teamfrom posthog.permissions import get_authenticator_scopes, is_authenticated_via_project_secret_api_keyfrom posthog.rate_limit import PersonalOrProjectSecretApiKeyRateThrottle, ProjectSecretApiKeyTeamRateThrottle@@ -141,6 +144,30 @@ class ExternalAccountProjectSecretAPIKeyAuthentication(ProjectSecretAPIKeyAuthenreturn result+class ExternalAccountPersonalAPIKeyAuthentication(PersonalAPIKeyAuthentication):+ def authenticate(self, request: HttpRequest | Request) -> tuple[Any, None] | None:+ try:+ return super().authenticate(request)+ except AuthenticationFailed:+ # DRF must reach the IP throttle before the view rejects an invalid key.+ return None+++class ExternalAccountPersonalKeyAccess(TeamAndOrgViewSetMixin, GenericViewSet):+ """Use the project API permission chain for a project selected on the external route."""++ scope_object = "account"+ action = "list"++ @classmethod+ def authorize(cls, request: Request, project_id: int) -> "ExternalAccountPersonalKeyAccess":+ access = cls()+ access.request = request+ access.kwargs = {"parent_lookup_team_id": project_id}+ access.check_permissions(request)+ return access++def _authenticate_team(request: Request) -> tuple[Team, None] | tuple[None, Response]:"""Extract Bearer token from Authorization header and validate against a team."""auth_header = request.headers.get("Authorization", "")@@ -341,6 +368,11 @@ class ExternalAccountView(APIView):class ExternalAccountListQuerySerializer(serializers.Serializer):+ project_id = serializers.IntegerField(+ required=False,+ min_value=1,+ help_text="Project ID. Required for personal API keys. Project secret API keys use their bound project.",+ )limit = serializers.IntegerField(required=False,default=EXTERNAL_ACCOUNT_LIST_MAX_LIMIT,@@ -441,6 +473,20 @@ class ExternalAccountListValidationErrorSerializer(serializers.Serializer):)+class ExternalAccountListPermissionErrorSerializer(serializers.Serializer):+ type = serializers.CharField(help_text="Error category.")+ code = serializers.CharField(help_text="Machine-readable error code.")+ detail = serializers.CharField(help_text="Error message.")+ attr = serializers.CharField(allow_null=True, help_text="Request field associated with the error, if any.")+++_ExternalAccountListAuthError = PolymorphicProxySerializer(+ component_name="ExternalAccountListAuthError",+ serializers=[ErrorResponseSerializer, ExternalAccountListPermissionErrorSerializer],+ resource_type_field_name=None,+)++class ExternalAccountListView(APIView):"""GET /api/customer_analytics/external/accounts — List accounts with their relationship assignments@@ -449,14 +495,18 @@ class ExternalAccountListView(APIView):to accounts with at least one active relationship assignment, which is whatthe billing service's ownership sync consumes.- Authenticated via a project secret API key (Bearer ``phs_...``) carrying the- ``account:read`` scope, not the team secret_api_token the sibling views+ Authenticated via a project secret API key (Bearer ``phs_...``) or a personal+ API key (Bearer ``phx_...``) carrying the ``account:read`` scope. Personal keys+ require ``project_id`` and follow the user's project and account permissions.+ This route does not accept the team secret_api_token the sibling viewsaccept. The team token is readable by any project member, so it must not- grant this team-wide export; a PSAK is a service credential minted with an- explicit scope.+ grant this team-wide export."""- authentication_classes = [ExternalAccountProjectSecretAPIKeyAuthentication]+ authentication_classes = [+ ExternalAccountProjectSecretAPIKeyAuthentication,+ ExternalAccountPersonalAPIKeyAuthentication,+ ]permission_classes = [AllowAny]throttle_classes = [ExternalAccountListBurstThrottle,@@ -474,10 +524,14 @@ class ExternalAccountListView(APIView):response=ExternalAccountListValidationErrorSerializer,description="Invalid query parameters.",),- 401: OpenApiResponse(response=ErrorResponseSerializer, description="Authentication failed."),+ 401: OpenApiResponse(response=_ExternalAccountListAuthError, description="Authentication failed."),403: OpenApiResponse(- response=ErrorResponseSerializer,- description="API key does not carry the account:read scope.",+ response=_ExternalAccountListAuthError,+ description="API key lacks the required scope or access to the selected project or accounts.",+ ),+ 404: OpenApiResponse(+ response=ExternalAccountListPermissionErrorSerializer,+ description="The project selected with a personal API key does not exist.",),},summary="List external customer analytics accounts",@@ -485,22 +539,41 @@ class ExternalAccountListView(APIView):"List tracked accounts with external IDs, lifecycle timestamps, controlled relationship ""ownership, and active relationship assignments. Set `include_ignored=true` to include ""ignored accounts and `managed_only=true` to read only the accounts customer analytics "- "holds ownership authority for. Requires a project secret API key with the `account:read` "- "scope."+ "holds ownership authority for. Requires a project secret API key or personal API key with the "+ "`account:read` scope. Personal API keys also require `project_id` and return only "+ "accounts the key owner can access."),)def get(self, request: Request) -> Response:- team, error = _authenticate_psak_team(request)- if error:- return error-- assert team is not None-+ personal_key = isinstance(request.successful_authenticator, PersonalAPIKeyAuthentication)+ team = None+ access = None+ if not personal_key:+ team, error = _authenticate_psak_team(request)+ if error:+ return errorquery_serializer = ExternalAccountListQuerySerializer(data=request.query_params)if not query_serializer.is_valid():return Response({"error": query_serializer.errors}, status=status.HTTP_400_BAD_REQUEST)query_data = query_serializer.validated_data+ if personal_key:+ if "project_id" not in query_data:+ return Response(+ {"error": {"project_id": ["Specify project_id when using a personal API key."]}},+ status=status.HTTP_400_BAD_REQUEST,+ )+ access = ExternalAccountPersonalKeyAccess.authorize(request, query_data["project_id"])+ team = access.team+ if not _customer_analytics_enabled(team):+ return Response({"error": "Missing or invalid API key"}, status=status.HTTP_401_UNAUTHORIZED)++ assert team is not None+ if "project_id" in query_data and query_data["project_id"] != team.id:+ return Response(+ {"error": "API key does not have access to this project."}, status=status.HTTP_403_FORBIDDEN+ )+page = facade.list_external_accounts(team.id,organization_id=team.organization_id,@@ -509,6 +582,7 @@ class ExternalAccountListView(APIView):assigned_only=query_data["assigned_only"],include_ignored=query_data["include_ignored"],managed_only=query_data["managed_only"],+ user_access_control=access.user_access_control if access else None,)return Response(ExternalAccountListPageSerializer(page).data)diff --git a/products/customer_analytics/backend/test/test_external_list.py b/products/customer_analytics/backend/test/test_external_list.pyindex e5d15862ca61..3b97b5902493 100644--- a/products/customer_analytics/backend/test/test_external_list.py+++ b/products/customer_analytics/backend/test/test_external_list.py@@ -1,3 +1,4 @@+import jsonfrom collections.abc import Iteratorfrom contextlib import contextmanagerfrom datetime import UTC, datetime@@ -13,10 +14,12 @@ from parameterized import parameterizedfrom rest_framework import statusfrom rest_framework.test import APIClient-from posthog.models import Organization, OrganizationMembership, Team, User-from posthog.models.utils import generate_random_token_secret+from posthog.constants import AvailableFeature+from posthog.models import Organization, OrganizationMembership, PersonalAPIKey, Team, User+from posthog.models.utils import generate_random_token_personal, generate_random_token_secret, hash_key_valuefrom posthog.test.api_keys import create_project_secret_api_key+from products.access_control.backend.models.access_control import AccessControlfrom products.customer_analytics.backend.facade import api as facadefrom products.customer_analytics.backend.models import AccountRelationship, AccountRelationshipDefinitionfrom products.customer_analytics.backend.test.factories import create_account, enroll_account@@ -43,6 +46,17 @@ class TestExternalAccountListAPI(APIBaseTest):_, token = create_project_secret_api_key(self.team, label=label, scopes=scopes)return token+ def _create_personal_token(self, scopes: list[str]) -> tuple[PersonalAPIKey, str]:+ token = generate_random_token_personal()+ key = PersonalAPIKey.objects.create(+ user=self.user,+ label="external-list",+ secure_value=hash_key_value(token),+ scopes=scopes,+ scoped_teams=[self.team.id],+ )+ return key, token+def _create_definition(self, name, **kwargs):return AccountRelationshipDefinition.objects.for_team(self.team.id).create(team_id=self.team.id, name=name, **kwargs@@ -103,7 +117,7 @@ class TestExternalAccountListAPI(APIBaseTest):def test_rejects_team_secret_api_token(self):# The team-wide secret token is readable by any project member, so it must- # not unlock this bulk export; only a scoped project secret API key may.+ # not unlock this bulk export without API scope checks.self.team.secret_api_token = generate_random_token_secret()self.team.save(update_fields=["secret_api_token"])@@ -111,13 +125,132 @@ class TestExternalAccountListAPI(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)- def test_rejects_key_without_account_read_scope(self):- token = self._create_psak_token(scopes=["endpoint:read"], label="wrong-scope")+ @parameterized.expand([("project",), ("personal",)])+ def test_rejects_key_without_account_read_scope(self, key_type: str) -> None:+ if key_type == "personal":+ _, token = self._create_personal_token(scopes=["endpoint:read"])+ else:+ token = self._create_psak_token(scopes=["endpoint:read"], label="wrong-scope")++ response = self._get(params={"project_id": self.team.id}, token=token)- response = self._get(token=token)+ self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)+ message = "API key missing required scope 'account:read'"+ self.assertEqual(+ response.json(), self.permission_denied_response(message) if key_type == "personal" else {"error": message}+ )++ @parameterized.expand([("missing", None), ("invalid", "abc"), ("negative", -1)])+ def test_personal_key_requires_valid_project_id(self, _name: str, project_id: str | int | None) -> None:+ _, token = self._create_personal_token(scopes=["account:read"])+ response = self._get(params={} if project_id is None else {"project_id": project_id}, token=token)+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)++ def test_personal_key_returns_not_found_for_deleted_project(self) -> None:+ project = Team.objects.create(organization=self.organization, name="Deleted project")+ project_id = project.id+ project.delete()+ _, token = self._create_personal_token(scopes=["account:read"])++ response = self._get(params={"project_id": project_id}, token=token)++ self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)+ self.assertEqual(response.json(), self.not_found_response("Project not found."))++ @parameterized.expand([("project_scope",), ("organization_scope",), ("membership",), ("resource_access",)])+ def test_personal_key_enforces_access(self, restriction: str) -> None:+ key, token = self._create_personal_token(scopes=["account:read"])+ if restriction == "project_scope":+ other_team = Team.objects.create(organization=self.organization, name="Other project")+ key.scoped_teams = [other_team.id]+ key.save()+ elif restriction == "organization_scope":+ other_org = Organization.objects.create(name="Other organization")+ key.scoped_organizations = [str(other_org.id)]+ key.save()+ elif restriction == "membership":+ OrganizationMembership.objects.filter(user=self.user, organization=self.organization).delete()+ else:+ self.organization.available_product_features = [+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS},+ ]+ self.organization.save()+ membership = OrganizationMembership.objects.get(user=self.user, organization=self.organization)+ membership.level = OrganizationMembership.Level.MEMBER+ membership.save()+ AccessControl.objects.create(+ team=self.team, resource="customer_analytics", access_level="none", organization_member=membership+ )+ response = self._get(params={"project_id": self.team.id}, token=token)self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)+ @parameterized.expand(+ [+ ("all", False, False),+ ("managed", True, False),+ ("all_resource_denied", False, True),+ ("managed_resource_denied", True, True),+ ]+ )+ def test_personal_key_filters_account_access_before_pagination(+ self, _name: str, managed_only: bool, resource_denied: bool+ ) -> None:+ self.organization.available_product_features = [+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS},+ ]+ self.organization.save()+ membership = OrganizationMembership.objects.get(user=self.user, organization=self.organization)+ membership.level = OrganizationMembership.Level.MEMBER+ membership.save()+ if resource_denied:+ AccessControl.objects.create(+ team=self.team, resource="customer_analytics", access_level="none", organization_member=membership+ )+ hidden = create_account(+ team_id=self.team.id,+ name="Hidden",+ external_id="hidden-account",+ created_by=self.user if resource_denied else None,+ )+ visible = create_account(team_id=self.team.id, name="Visible", external_id="visible-account")+ if managed_only:+ self.csm_definition.is_controlled = True+ self.csm_definition.save(update_fields=["is_controlled"])+ enroll_account(hidden, self.csm_definition, controlled_at=ENDED_AT)+ enroll_account(visible, self.csm_definition, controlled_at=ENDED_AT)+ AccessControl.objects.create(+ team=self.team,+ resource="account",+ resource_id=str(visible.id if resource_denied else hidden.id),+ access_level="viewer" if resource_denied else "none",+ organization_member=membership,+ )+ _, token = self._create_personal_token(scopes=["account:read"])++ response = self._get(+ params={"project_id": self.team.id, "limit": 1, "managed_only": str(managed_only).lower()}, token=token+ )++ self.assertEqual(response.status_code, status.HTTP_200_OK)+ self.assertEqual(+ [row["external_id"] for row in response.json()["results"]], [] if resource_denied else [visible.external_id]+ )+ self.assertIsNone(response.json()["next_cursor"])++ def test_personal_key_respects_feature_gate(self) -> None:+ _, token = self._create_personal_token(scopes=["account:read"])+ self.mock_csp_enabled.return_value = False+ self.assertEqual(+ self._get(params={"project_id": self.team.id}, token=token).status_code, status.HTTP_401_UNAUTHORIZED+ )++ def test_project_key_cannot_select_another_project(self) -> None:+ other_team = Team.objects.create(organization=self.organization, name="Other project")+ self.assertEqual(self._get(params={"project_id": other_team.id}).status_code, status.HTTP_403_FORBIDDEN)+def test_disabled_feature_does_not_reveal_key_validity_or_scopes(self):wrong_scope_token = self._create_psak_token(scopes=["endpoint:read"], label="wrong-scope-disabled")self.mock_csp_enabled.return_value = False@@ -137,17 +270,21 @@ class TestExternalAccountListAPI(APIBaseTest):self.assertEqual(self._get().status_code, status.HTTP_200_OK)self.assertEqual(self._get(token=second_token).status_code, status.HTTP_429_TOO_MANY_REQUESTS)- def test_invalid_tokens_share_ip_rate_limit(self):+ @parameterized.expand(+ [("project", "project"), ("personal", "personal"), ("project", "personal"), ("personal", "project")]+ )+ def test_invalid_tokens_share_ip_rate_limit(self, first_key_type: str, second_key_type: str) -> None:cache.clear()self.addCleanup(cache.clear)+ token_generators = {"project": generate_random_token_secret, "personal": generate_random_token_personal}with self._rate_limits(key_rate="1/minute", team_rate="100/minute"):self.assertEqual(- self._get(token=generate_random_token_secret()).status_code,+ self._get(token=token_generators[first_key_type]()).status_code,status.HTTP_401_UNAUTHORIZED,)self.assertEqual(- self._get(token=generate_random_token_secret()).status_code,+ self._get(token=token_generators[second_key_type]()).status_code,status.HTTP_429_TOO_MANY_REQUESTS,)@@ -165,7 +302,19 @@ class TestExternalAccountListAPI(APIBaseTest):# -- Listing ----------------------------------------------------------- def test_lists_accounts_with_relationship_assignments(self):+ @parameterized.expand(+ [+ ("project",),+ ("personal_read",),+ ("personal_write",),+ ("personal_all",),+ ("personal_legacy",),+ ("personal_whitespace",),+ ("personal_query",),+ ("personal_body",),+ ]+ )+ def test_lists_accounts_with_relationship_assignments(self, key_type: str) -> None:self.user.first_name = "Anna"self.user.last_name = "Exec"self.user.save(update_fields=["first_name", "last_name"])@@ -181,7 +330,29 @@ class TestExternalAccountListAPI(APIBaseTest):self._assign(account, self.user, definition=ae_definition)self._assign(account, colleague, definition=ae_definition)- response = self._get()+ if key_type == "project":+ response = self._get()+ else:+ scope = {"personal_write": "account:write", "personal_all": "*"}.get(key_type, "account:read")+ key, token = self._create_personal_token(scopes=[scope])+ if key_type == "personal_legacy":+ token = token.removeprefix("phx_")+ key.secure_value = hash_key_value(token)+ key.save(update_fields=["secure_value"])+ if key_type == "personal_query":+ response = self.client.get(self.url, data={"project_id": str(self.team.id), "personal_api_key": token})+ elif key_type == "personal_body":+ response = self.client.generic(+ "GET",+ f"{self.url}?project_id={self.team.id}",+ data=json.dumps({"personal_api_key": token}),+ content_type="application/json",+ )+ else:+ separator = "\t " if key_type == "personal_whitespace" else " "+ response = self.client.get(+ self.url, data={"project_id": self.team.id}, HTTP_AUTHORIZATION=f"Bearer{separator}{token}"+ )self.assertEqual(response.status_code, status.HTTP_200_OK)data = response.json()diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.tsindex 80b53711fba9..3ede9b98a6c9 100644--- a/products/customer_analytics/frontend/generated/api.schemas.ts+++ b/products/customer_analytics/frontend/generated/api.schemas.ts@@ -224,6 +224,22 @@ export interface ErrorResponseApi {error: string}+export interface ExternalAccountListPermissionErrorApi {+ /** Error category. */+ type: string+ /** Machine-readable error code. */+ code: string+ /** Error message. */+ detail: string+ /**+ * Request field associated with the error, if any.+ * @nullable+ */+ attr: string | null+}++export type ExternalAccountListAuthErrorApi = ErrorResponseApi | ExternalAccountListPermissionErrorApi+/*** * `engineering` - Engineering* * `data` - Data@@ -4260,6 +4276,11 @@ export type CustomerAnalyticsExternalAccountsRetrieveParams = {* When true, return only accounts where customer analytics holds authority over at least one controlled relationship, including accounts whose managed relationships are cleared and accounts that are ignored. Authority does not end when an account is ignored, so `include_ignored` is implied.*/managed_only?: boolean+ /**+ * Project ID. Required for personal API keys. Project secret API keys use their bound project.+ * @minimum 1+ */+ project_id?: number}export type AccountNotesListParams = {diff --git a/products/customer_analytics/frontend/generated/api.ts b/products/customer_analytics/frontend/generated/api.tsindex 13c65b95e5a6..2efb069ef542 100644--- a/products/customer_analytics/frontend/generated/api.ts+++ b/products/customer_analytics/frontend/generated/api.ts@@ -187,7 +187,7 @@ export const getCustomerAnalyticsExternalAccountsRetrieveUrl = (}/**- * List tracked accounts with external IDs, lifecycle timestamps, controlled relationship ownership, and active relationship assignments. Set `include_ignored=true` to include ignored accounts and `managed_only=true` to read only the accounts customer analytics holds ownership authority for. Requires a project secret API key with the `account:read` scope.+ * List tracked accounts with external IDs, lifecycle timestamps, controlled relationship ownership, and active relationship assignments. Set `include_ignored=true` to include ignored accounts and `managed_only=true` to read only the accounts customer analytics holds ownership authority for. Requires a project secret API key or personal API key with the `account:read` scope. Personal API keys also require `project_id` and return only accounts the key owner can access.* @summary List external customer analytics accounts*/export const customerAnalyticsExternalAccountsRetrieve = async (diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex eba240222846..d44459ee0145 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -38705,6 +38705,22 @@ export namespace Schemas {name: string | null;}+ export interface ExternalAccountListPermissionError {+ /** Error category. */+ type: string;+ /** Machine-readable error code. */+ code: string;+ /** Error message. */+ detail: string;+ /**+ * Request field associated with the error, if any.+ * @nullable+ */+ attr: string | null;+ }++ export type ExternalAccountListAuthError = ErrorResponse | ExternalAccountListPermissionError;+/*** Active relationship assignments to current organization members, keyed by relationship definition name (e.g. 'CSM', 'Account executive'). Definitions with no active assignment are omitted.*/@@ -97656,6 +97672,11 @@ export namespace Schemas {* When true, return only accounts where customer analytics holds authority over at least one controlled relationship, including accounts whose managed relationships are cleared and accounts that are ignored. Authority does not end when an account is ignored, so `include_ignored` is implied.*/managed_only?: boolean;+ /**+ * Project ID. Required for personal API keys. Project secret API keys use their bound project.+ * @minimum 1+ */+ project_id?: number;};export type FeatureFlagsStaffCacheListParams = {