Skip to content

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

feat(dashboards): add batch widget settings update endpoint + MCP tool (#65564)

Matt Puaaa90765c68ef
diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.py
index 7d7270293b20..4ee370c15723 100644
--- a/products/dashboards/backend/api/dashboard.py
+++ b/products/dashboards/backend/api/dashboard.py
@@ -89,6 +89,7 @@ from products.dashboards.backend.api.widget_openapi_serializers import (
AddDashboardWidgetRequestOpenApi,
DashboardWidgetConfigField,
PatchedDashboardOpenApiSerializer,
+ UpdateDashboardWidgetRequestOpenApi,
WidgetCatalogResponseSerializer,
)
from products.dashboards.backend.constants import DASHBOARD_GRID_COLUMN_COUNT, MAX_WIDGETS_BATCH_SIZE
@@ -593,6 +594,63 @@ class AddDashboardWidgetsBatchRequestOpenApiSerializer(serializers.Serializer):
)
+class UpdateWidgetRequestSerializer(serializers.Serializer):
+ tile_id = serializers.IntegerField(
+ required=True,
+ help_text="ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ )
+ widget_type = serializers.ChoiceField(
+ choices=sorted(EXPECTED_WIDGET_TYPES),
+ required=False,
+ help_text=f"{WIDGET_TYPE_API_HELP} Immutable; provide only to pick the config shape.",
+ )
+ config = DashboardWidgetConfigField(
+ required=False,
+ help_text=(
+ "New widget configuration. Shape depends on the tile's widget_type; see "
+ "dashboard-widget-catalog-list for per-type config_schema. Omit to leave unchanged."
+ ),
+ )
+ name = serializers.CharField(
+ max_length=400,
+ required=False,
+ allow_null=True,
+ allow_blank=True,
+ help_text="New display name for the widget tile. Empty string or null clears it; omit to leave unchanged.",
+ )
+ description = serializers.CharField(
+ required=False,
+ allow_blank=True,
+ help_text="New markdown description for the widget. Omit to leave unchanged.",
+ )
+
+
+class UpdateDashboardWidgetsBatchRequestSerializer(serializers.Serializer):
+ widgets = serializers.ListField(
+ child=UpdateWidgetRequestSerializer(),
+ min_length=1,
+ max_length=MAX_WIDGETS_BATCH_SIZE,
+ help_text=(
+ f"Widget tiles to update atomically (1–{MAX_WIDGETS_BATCH_SIZE}), each identified by its tile_id. "
+ "Use a single-element list to update one widget."
+ ),
+ )
+
+
+class UpdateDashboardWidgetsBatchRequestOpenApiSerializer(serializers.Serializer):
+ """OpenAPI-only batch-update schema with widget_type-discriminated config shapes for agents."""
+
+ widgets = serializers.ListField(
+ child=UpdateDashboardWidgetRequestOpenApi,
+ min_length=1,
+ max_length=MAX_WIDGETS_BATCH_SIZE,
+ help_text=(
+ "Widget tiles to update atomically, each identified by its tile_id. config shape is per widget_type; "
+ f"see dashboard-widget-catalog-list for per-type config_schema (1–{MAX_WIDGETS_BATCH_SIZE} per request)."
+ ),
+ )
+
+
class CanEditDashboard(BasePermission):
message = "You don't have edit permissions for this dashboard."
@@ -827,6 +885,13 @@ class AddDashboardWidgetsBatchResponseSerializer(serializers.Serializer):
)
+class UpdateDashboardWidgetsBatchResponseSerializer(serializers.Serializer):
+ tiles = DashboardTileSerializer(
+ many=True,
+ help_text="Updated dashboard widget tiles in request order.",
+ )
+
+
class DashboardBasicSerializer(
SearchMatchTypeSerializerMixin,
TaggedItemSerializerMixin,
@@ -1105,6 +1170,36 @@ def _report_dashboard_tile_removed(
)
+def _report_dashboard_widget_updated(
+ *,
+ user: User,
+ dashboard: Dashboard,
+ tile: DashboardTile,
+ fields_changed: builtins.list[str],
+ request: Request | None = None,
+) -> None:
+ # Fired only by the dedicated widgets/batch_update endpoint, so it doubles as the signal for
+ # whether agents reach for this path rather than the generic dashboard PATCH.
+ if tile.widget is None:
+ return
+ properties: dict[str, Any] = {
+ "widget_type": tile.widget.widget_type,
+ "dashboard_id": dashboard.id,
+ "tile_id": tile.id,
+ "fields_changed": fields_changed,
+ }
+ if tile.widget_id is not None:
+ properties["widget_id"] = str(tile.widget_id)
+
+ report_user_action(
+ user,
+ "dashboard widget updated",
+ properties,
+ team=dashboard.team,
+ request=request,
+ )
+
+
class DashboardSerializer(DashboardMetadataSerializer):
tiles = serializers.SerializerMethodField()
use_template = serializers.CharField(
@@ -2928,6 +3023,98 @@ class DashboardsViewSet(
**tile_defaults,
)
+ @extend_schema(
+ operation_id="dashboards_update_widgets_batch",
+ request=UpdateDashboardWidgetsBatchRequestOpenApiSerializer,
+ responses={200: UpdateDashboardWidgetsBatchResponseSerializer},
+ )
+ @action(methods=["PATCH"], detail=True, url_path="widgets/batch_update", required_scopes=["dashboard:write"])
+ def update_widgets_batch(self, request: Request, *args: Any, **kwargs: Any) -> Response:
+ """Update the settings of existing widgets in place, atomically — config, name, and description.
+
+ Each entry targets a widget by its tile_id and reuses the same write path as the dashboard PATCH endpoint.
+ The widget_type is immutable. This edits widget settings only (config, name, description); tile placement
+ (layouts, show_description) is a dashboard concern — use the dashboard PATCH endpoint or reorder_tiles for
+ that. All updates succeed or fail together. To add new widgets, use the widgets/batch POST endpoint; to
+ remove one, use delete_tile.
+ """
+ if not dashboard_widgets_enabled(team=self.team, user=cast(User, request.user)):
+ raise exceptions.ValidationError("Dashboard widgets are not enabled for this project.")
+
+ dashboard = self.get_object()
+ if dashboard.deleted:
+ raise exceptions.NotFound()
+ if not self.user_permissions.dashboard(dashboard).can_edit:
+ raise exceptions.PermissionDenied("You don't have edit permissions for this dashboard.")
+
+ serializer = UpdateDashboardWidgetsBatchRequestSerializer(data=request.data)
+ serializer.is_valid(raise_exception=True)
+ widget_payloads = cast(builtins.list[dict[str, Any]], serializer.validated_data["widgets"])
+
+ user = cast(User, request.user)
+ user_access_control = UserAccessControl(user=user, team=self.team)
+
+ with transaction.atomic():
+ tiles = [
+ self._apply_widget_tile_update(
+ dashboard=dashboard,
+ user=user,
+ user_access_control=user_access_control,
+ payload=payload,
+ request=request,
+ )
+ for payload in widget_payloads
+ ]
+
+ for tile in tiles:
+ tile.refresh_from_db()
+
+ # Report after the transaction commits so a rolled-back batch never emits events.
+ for tile, payload in zip(tiles, widget_payloads):
+ _report_dashboard_widget_updated(
+ user=user,
+ dashboard=dashboard,
+ tile=tile,
+ fields_changed=[field for field in ("config", "name", "description") if field in payload],
+ request=request,
+ )
+
+ tile_context = {**self.get_serializer_context(), "dashboard": dashboard}
+ return Response({"tiles": DashboardTileSerializer(tiles, context=tile_context, many=True).data})
+
+ def _apply_widget_tile_update(
+ self,
+ *,
+ dashboard: Dashboard,
+ user: User,
+ user_access_control: UserAccessControl,
+ payload: dict[str, Any],
+ request: Request,
+ ) -> DashboardTile:
+ tile = get_object_or_404(
+ DashboardTile,
+ id=payload["tile_id"],
+ dashboard=dashboard,
+ dashboard__team__project_id=self.team.project_id,
+ )
+ if tile.widget is None:
+ raise exceptions.ValidationError(f"Tile {payload['tile_id']} is not a widget tile.")
+
+ widget_data: dict[str, Any] = {
+ field: payload[field] for field in ("widget_type", "config", "name", "description") if field in payload
+ }
+ if widget_data:
+ DashboardSerializer._apply_patch_widget_update(
+ widget=tile.widget,
+ widget_data=widget_data,
+ user=user,
+ user_access_control=user_access_control,
+ dashboard=dashboard,
+ request=request,
+ )
+
+ return tile
+
def _format_insight_for_llm(self, insight: Insight, insight_data: dict) -> str | None:
if not settings.EE_AVAILABLE:
return None
diff --git a/products/dashboards/backend/api/test/test_dashboard_widgets.py b/products/dashboards/backend/api/test/test_dashboard_widgets.py
index 69e3a09c31fb..9b282cf8c173 100644
--- a/products/dashboards/backend/api/test/test_dashboard_widgets.py
+++ b/products/dashboards/backend/api/test/test_dashboard_widgets.py
@@ -2,7 +2,7 @@ from typing import Any
from freezegun import freeze_time
from posthog.test.base import APIBaseTest
-from unittest.mock import ANY, patch
+from unittest.mock import ANY, PropertyMock, patch
from django.test import override_settings
@@ -1147,6 +1147,315 @@ class TestDashboardWidgets(APIBaseTest):
assert shared_widget["config"]["limit"] == 10
+class TestDashboardWidgetsBatchUpdate(APIBaseTest):
+ _WIDGETS_FLAG_PATCH_TARGETS = TestDashboardWidgets._WIDGETS_FLAG_PATCH_TARGETS
+
+ def setUp(self) -> None:
+ super().setUp()
+ self.dashboard_api = DashboardAPI(self.client, self.team, self.assertEqual)
+ self._widgets_flag_patchers = [patch(target, return_value=True) for target in self._WIDGETS_FLAG_PATCH_TARGETS]
+ for patcher in self._widgets_flag_patchers:
+ patcher.start()
+
+ def tearDown(self) -> None:
+ for patcher in self._widgets_flag_patchers:
+ patcher.stop()
+ super().tearDown()
+
+ def _batch_update(self, dashboard_id: int, widgets: list[dict[str, Any]], team_id: int | None = None) -> Any:
+ team_id = team_id or self.team.id
+ return self.client.patch(
+ f"/api/projects/{team_id}/dashboards/{dashboard_id}/widgets/batch_update/",
+ {"widgets": widgets},
+ )
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_updates_widget_config_in_place(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(
+ dashboard_id, config={"limit": 5, "orderBy": "last_seen"}
+ )
+ tile = dashboard_json["tiles"][0]
+
+ response = self._batch_update(
+ dashboard_id,
+ [{"tile_id": tile["id"], "config": {"limit": 15, "orderBy": "occurrences"}}],
+ )
+ assert response.status_code == status.HTTP_200_OK
+
+ updated_tile = response.json()["tiles"][0]
+ assert updated_tile["widget"]["config"]["limit"] == 15
+ assert updated_tile["widget"]["config"]["orderBy"] == "occurrences"
+ # The widget row is edited in place, not recreated.
+ assert updated_tile["widget"]["id"] == tile["widget"]["id"]
+ assert updated_tile["id"] == tile["id"]
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_updates_widget_name_and_description(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id)
+ tile = dashboard_json["tiles"][0]
+
+ response = self._batch_update(
+ dashboard_id,
+ [{"tile_id": tile["id"], "name": "My top errors", "description": "Worst issues this week"}],
+ )
+ assert response.status_code == status.HTTP_200_OK
+
+ updated_tile = response.json()["tiles"][0]
+ assert updated_tile["widget"]["name"] == "My top errors"
+ assert updated_tile["widget"]["description"] == "Worst issues this week"
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_partial_update_preserves_other_settings(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(
+ dashboard_id, config={"limit": 5, "orderBy": "last_seen"}
+ )
+ tile = dashboard_json["tiles"][0]
+
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "name": "Renamed"}])
+ assert response.status_code == status.HTTP_200_OK
+
+ updated_tile = response.json()["tiles"][0]
+ assert updated_tile["widget"]["name"] == "Renamed"
+ assert updated_tile["widget"]["config"]["limit"] == 5
+ assert updated_tile["widget"]["config"]["orderBy"] == "last_seen"
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_sets_session_replay_saved_filter_id(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(
+ dashboard_id, widget_type="session_replay_list", config={"limit": 5}
+ )
+ tile = dashboard_json["tiles"][0]
+
+ response = self._batch_update(
+ dashboard_id,
+ [{"tile_id": tile["id"], "config": {"limit": 5, "savedFilterId": "abc123"}}],
+ )
+ assert response.status_code == status.HTTP_200_OK
+
+ updated_tile = response.json()["tiles"][0]
+ assert updated_tile["widget"]["config"]["savedFilterId"] == "abc123"
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_updates_multiple_widgets_atomically(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tiles = self.dashboard_api.get_dashboard(dashboard_id)["tiles"]
+ assert len(tiles) == 2
+
+ response = self._batch_update(
+ dashboard_id,
+ [
+ {"tile_id": tiles[0]["id"], "config": {"limit": 11}},
+ {"tile_id": tiles[1]["id"], "config": {"limit": 22}},
+ ],
+ )
+ assert response.status_code == status.HTTP_200_OK
+
+ limits = sorted(t["widget"]["config"]["limit"] for t in response.json()["tiles"])
+ assert limits == [11, 22]
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_batch_update_is_atomic(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tiles = self.dashboard_api.get_dashboard(dashboard_id)["tiles"]
+
+ # Second entry has an out-of-range limit; the whole batch must roll back.
+ response = self._batch_update(
+ dashboard_id,
+ [
+ {"tile_id": tiles[0]["id"], "config": {"limit": 15}},
+ {"tile_id": tiles[1]["id"], "config": {"limit": 999}},
+ ],
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+ after = self.dashboard_api.get_dashboard(dashboard_id)["tiles"]
+ assert all(t["widget"]["config"]["limit"] == 5 for t in after)
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_cannot_change_widget_type(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 10})
+ tile = dashboard_json["tiles"][0]
+
+ response = self._batch_update(
+ dashboard_id,
+ [{"tile_id": tile["id"], "widget_type": "session_replay_list", "config": {"limit": 10}}],
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "widget_type cannot be changed" in response.json()["detail"]
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_rejects_non_widget_tile(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ dashboard = Dashboard.objects.get(id=dashboard_id)
+ insight = Insight.objects.create(team=self.team, name="an insight")
+ insight_tile = DashboardTile.objects.create(
+ dashboard=dashboard, team_id=self.team.id, insight=insight, layouts={}
+ )
+
+ response = self._batch_update(dashboard_id, [{"tile_id": insight_tile.id, "config": {"limit": 5}}])
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "not a widget tile" in response.json()["detail"]
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_rejects_unknown_tile_id(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+
+ response = self._batch_update(dashboard_id, [{"tile_id": 99999999, "config": {"limit": 5}}])
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_cannot_update_tile_from_another_dashboard(self) -> None:
+ dashboard_a, _ = self.dashboard_api.create_dashboard({"name": "a"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_a, config={"limit": 5})
+ foreign_tile_id = dashboard_json["tiles"][0]["id"]
+ dashboard_b, _ = self.dashboard_api.create_dashboard({"name": "b"})
+
+ response = self._batch_update(dashboard_b, [{"tile_id": foreign_tile_id, "config": {"limit": 9}}])
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_requires_feature_flag(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tile = dashboard_json["tiles"][0]
+
+ for patcher in self._widgets_flag_patchers:
+ patcher.stop()
+ try:
+ with patch(
+ "products.dashboards.backend.api.dashboard.dashboard_widgets_enabled",
+ return_value=False,
+ ):
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 9}}])
+ finally:
+ for patcher in self._widgets_flag_patchers:
+ patcher.start()
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "not enabled" in response.json()["detail"].lower()
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_rejects_empty_list(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+
+ response = self._batch_update(dashboard_id, [])
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_does_not_touch_tile_placement(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tile = dashboard_json["tiles"][0]
+ layout = {"sm": {"x": 0, "y": 3, "w": 6, "h": 4}}
+ self.client.patch(
+ f"/api/projects/{self.team.id}/dashboards/{dashboard_id}",
+ {"tiles": [{"id": tile["id"], "layouts": layout}]},
+ )
+
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 12}}])
+ assert response.status_code == status.HTTP_200_OK
+
+ after = self.dashboard_api.get_dashboard(dashboard_id)["tiles"][0]
+ assert after["widget"]["config"]["limit"] == 12
+ assert after["layouts"] == layout
+
+ @override_settings(IN_UNIT_TESTING=True)
+ @patch("products.dashboards.backend.api.dashboard.report_user_action")
+ def test_update_does_not_fire_tile_added_event(self, mock_report_user_action) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tile = dashboard_json["tiles"][0]
+ mock_report_user_action.reset_mock()
+
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 15}}])
+ assert response.status_code == status.HTTP_200_OK
+
+ for call in mock_report_user_action.call_args_list:
+ assert call[0][1] != "dashboard tile added"
+ assert call[0][1] != "dashboard widget added"
+
+ @override_settings(IN_UNIT_TESTING=True)
+ @patch("products.dashboards.backend.api.dashboard.report_user_action")
+ def test_update_fires_widget_updated_event(self, mock_report_user_action) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tile = dashboard_json["tiles"][0]
+ mock_report_user_action.reset_mock()
+
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "name": "Renamed"}])
+ assert response.status_code == status.HTTP_200_OK
+
+ updated_events = [
+ call for call in mock_report_user_action.call_args_list if call[0][1] == "dashboard widget updated"
+ ]
+ assert len(updated_events) == 1
+ properties = updated_events[0][0][2]
+ assert properties["tile_id"] == tile["id"]
+ assert properties["fields_changed"] == ["name"]
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_denies_without_edit_permission(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tile = dashboard_json["tiles"][0]
+
+ with patch(
+ "posthog.user_permissions.UserDashboardPermissions.can_edit",
+ new_callable=PropertyMock,
+ return_value=False,
+ ):
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 9}}])
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_rejects_update_on_deleted_dashboard(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 5})
+ tile = dashboard_json["tiles"][0]
+ Dashboard.objects.filter(id=dashboard_id).update(deleted=True)
+
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 9}}])
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
+ @override_settings(IN_UNIT_TESTING=True)
+ def test_denies_without_product_access(self) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
+ _, dashboard_json = self.dashboard_api.create_widget_tile(dashboard_id, config={"limit": 10})
+ tile = dashboard_json["tiles"][0]
+
+ real_check = UserAccessControl.check_access_level_for_resource
+
+ def deny_error_tracking_only(
+ user_access_control: UserAccessControl,
+ resource: APIScopeObject,
+ required_level: AccessControlLevel = "viewer",
+ ) -> bool:
+ if resource == "error_tracking":
+ return False
+ return real_check(user_access_control, resource, required_level)
+
+ with patch.object(
+ UserAccessControl,
+ "check_access_level_for_resource",
+ autospec=True,
+ side_effect=deny_error_tracking_only,
+ ):
+ response = self._batch_update(dashboard_id, [{"tile_id": tile["id"], "config": {"limit": 12}}])
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ assert response.json()["detail"] == "You do not have access to error tracking."
+
+
class TestDashboardWidgetOpenApiSchema(APIBaseTest):
def setUp(self) -> None:
super().setUp()
@@ -1169,6 +1478,13 @@ class TestDashboardWidgetOpenApiSchema(APIBaseTest):
assert component["discriminator"]["propertyName"] == "widget_type"
assert set(component["discriminator"]["mapping"].keys()) == set(EXPECTED_WIDGET_TYPES)
+ def test_update_dashboard_widget_openapi_schema_uses_widget_type_discriminator(self) -> None:
+ schema = SchemaGenerator().get_schema(request=None, public=True)
+ component = schema["components"]["schemas"]["UpdateDashboardWidgetRequest"]
+
+ assert component["discriminator"]["propertyName"] == "widget_type"
+ assert set(component["discriminator"]["mapping"].keys()) == set(EXPECTED_WIDGET_TYPES)
+
def test_batch_add_rejects_unknown_widget_type(self) -> None:
dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dash"})
response = self.client.post(
diff --git a/products/dashboards/backend/api/widget_openapi_serializers.py b/products/dashboards/backend/api/widget_openapi_serializers.py
index 5e2ee42e012a..a5f605b5576a 100644
--- a/products/dashboards/backend/api/widget_openapi_serializers.py
+++ b/products/dashboards/backend/api/widget_openapi_serializers.py
@@ -15,6 +15,7 @@ from products.dashboards.backend.widget_specs.openapi import (
DashboardWidgetConfigField,
DashboardWidgetConfigOpenApi,
PatchedDashboardOpenApiSerializer,
+ UpdateDashboardWidgetRequestOpenApi,
WidgetCatalogEntryOpenApi,
WidgetCatalogResponseSerializer,
)
@@ -26,6 +27,7 @@ __all__ = [
"DashboardWidgetConfigField",
"DashboardWidgetConfigOpenApi",
"PatchedDashboardOpenApiSerializer",
+ "UpdateDashboardWidgetRequestOpenApi",
"WidgetCatalogEntryOpenApi",
"WidgetCatalogResponseSerializer",
"WIDGET_BATCH_ADD_OPENAPI_HELP",
diff --git a/products/dashboards/backend/widget_specs/openapi.py b/products/dashboards/backend/widget_specs/openapi.py
index 1a954b7e102f..6824a6c17f39 100644
--- a/products/dashboards/backend/widget_specs/openapi.py
+++ b/products/dashboards/backend/widget_specs/openapi.py
@@ -147,6 +147,52 @@ AddDashboardWidgetRequestOpenApi = PolymorphicProxySerializer(
resource_type_field_name="widget_type",
)
+
+class _UpdateDashboardWidgetTileFieldsOpenApiSerializer(serializers.Serializer):
+ tile_id = serializers.IntegerField(
+ help_text="ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ )
+ name = serializers.CharField(
+ max_length=400,
+ required=False,
+ allow_null=True,
+ allow_blank=True,
+ help_text="New display name for the widget. Empty string or null clears it; omit to leave unchanged.",
+ )
+ description = serializers.CharField(
+ required=False,
+ allow_blank=True,
+ help_text="New markdown description for the widget. Omit to leave unchanged.",
+ )
+
+
+def _build_update_request_serializers() -> dict[str, type[serializers.Serializer]]:
+ update_request_serializers: dict[str, type[serializers.Serializer]] = {}
+ for widget_type, spec in WIDGET_SPECS.items():
+ prefix = _config_model_openapi_prefix(spec.config_model)
+ update_request_serializers[widget_type] = type(
+ f"{prefix}UpdateRequestOpenApiSerializer",
+ (_UpdateDashboardWidgetTileFieldsOpenApiSerializer,),
+ {
+ "widget_type": serializers.ChoiceField(choices=[widget_type]),
+ "config": pydantic_config_field(
+ spec.config_model,
+ required=False,
+ help_text=f"New configuration for the {spec.label.lower()} widget. Omit to leave unchanged.",
+ ),
+ },
+ )
+ return update_request_serializers
+
+
+_WIDGET_UPDATE_REQUEST_SERIALIZERS = _build_update_request_serializers()
+
+UpdateDashboardWidgetRequestOpenApi = PolymorphicProxySerializer(
+ component_name="UpdateDashboardWidgetRequest",
+ serializers=cast("dict[str, Any]", _WIDGET_UPDATE_REQUEST_SERIALIZERS),
+ resource_type_field_name="widget_type",
+)
+
WidgetCatalogEntryOpenApi = PolymorphicProxySerializer(
component_name="WidgetCatalogEntry",
serializers=cast("dict[str, Any]", _WIDGET_CATALOG_ENTRY_SERIALIZERS),
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index d9d020b96ea6..0362688a2398 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -8236,6 +8236,145 @@ export interface AddDashboardWidgetsBatchResponseApi {
tiles: DashboardTileApi[]
}
+export type ActivityEventsListWidgetUpdateRequestOpenApiApiWidgetType =
+ (typeof ActivityEventsListWidgetUpdateRequestOpenApiApiWidgetType)[keyof typeof ActivityEventsListWidgetUpdateRequestOpenApiApiWidgetType]
+
+export const ActivityEventsListWidgetUpdateRequestOpenApiApiWidgetType = {
+ ActivityEventsList: 'activity_events_list',
+} as const
+
+export interface ActivityEventsListWidgetUpdateRequestOpenApiApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string
+ widget_type: ActivityEventsListWidgetUpdateRequestOpenApiApiWidgetType
+ /** New configuration for the recent events widget. Omit to leave unchanged. */
+ config?: ActivityEventsListWidgetConfigApi
+}
+
+export type ErrorTrackingListWidgetUpdateRequestOpenApiApiWidgetType =
+ (typeof ErrorTrackingListWidgetUpdateRequestOpenApiApiWidgetType)[keyof typeof ErrorTrackingListWidgetUpdateRequestOpenApiApiWidgetType]
+
+export const ErrorTrackingListWidgetUpdateRequestOpenApiApiWidgetType = {
+ ErrorTrackingList: 'error_tracking_list',
+} as const
+
+export interface ErrorTrackingListWidgetUpdateRequestOpenApiApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string
+ widget_type: ErrorTrackingListWidgetUpdateRequestOpenApiApiWidgetType
+ /** New configuration for the top issues widget. Omit to leave unchanged. */
+ config?: ErrorTrackingListWidgetConfigApi
+}
+
+export type SessionReplayListWidgetUpdateRequestOpenApiApiWidgetType =
+ (typeof SessionReplayListWidgetUpdateRequestOpenApiApiWidgetType)[keyof typeof SessionReplayListWidgetUpdateRequestOpenApiApiWidgetType]
+
+export const SessionReplayListWidgetUpdateRequestOpenApiApiWidgetType = {
+ SessionReplayList: 'session_replay_list',
+} as const
+
+export interface SessionReplayListWidgetUpdateRequestOpenApiApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string
+ widget_type: SessionReplayListWidgetUpdateRequestOpenApiApiWidgetType
+ /** New configuration for the recent recordings widget. Omit to leave unchanged. */
+ config?: SessionReplayListWidgetConfigApi
+}
+
+export type ExperimentsListWidgetUpdateRequestOpenApiApiWidgetType =
+ (typeof ExperimentsListWidgetUpdateRequestOpenApiApiWidgetType)[keyof typeof ExperimentsListWidgetUpdateRequestOpenApiApiWidgetType]
+
+export const ExperimentsListWidgetUpdateRequestOpenApiApiWidgetType = {
+ ExperimentsList: 'experiments_list',
+} as const
+
+export interface ExperimentsListWidgetUpdateRequestOpenApiApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string
+ widget_type: ExperimentsListWidgetUpdateRequestOpenApiApiWidgetType
+ /** New configuration for the experiments list widget. Omit to leave unchanged. */
+ config?: ExperimentsListWidgetConfigApi
+}
+
+export type ExperimentResultsWidgetUpdateRequestOpenApiApiWidgetType =
+ (typeof ExperimentResultsWidgetUpdateRequestOpenApiApiWidgetType)[keyof typeof ExperimentResultsWidgetUpdateRequestOpenApiApiWidgetType]
+
+export const ExperimentResultsWidgetUpdateRequestOpenApiApiWidgetType = {
+ ExperimentResults: 'experiment_results',
+} as const
+
+export interface ExperimentResultsWidgetUpdateRequestOpenApiApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string
+ widget_type: ExperimentResultsWidgetUpdateRequestOpenApiApiWidgetType
+ /** New configuration for the experiment results widget. Omit to leave unchanged. */
+ config?: ExperimentResultsWidgetConfigApi
+}
+
+export type UpdateDashboardWidgetRequestApi =
+ | ActivityEventsListWidgetUpdateRequestOpenApiApi
+ | ErrorTrackingListWidgetUpdateRequestOpenApiApi
+ | SessionReplayListWidgetUpdateRequestOpenApiApi
+ | ExperimentsListWidgetUpdateRequestOpenApiApi
+ | ExperimentResultsWidgetUpdateRequestOpenApiApi
+
+/**
+ * OpenAPI-only batch-update schema with widget_type-discriminated config shapes for agents.
+ */
+export interface PatchedUpdateDashboardWidgetsBatchRequestOpenApiApi {
+ /**
+ * Widget tiles to update atomically, each identified by its tile_id. config shape is per widget_type; see dashboard-widget-catalog-list for per-type config_schema (1–10 per request).
+ * @minItems 1
+ * @maxItems 10
+ */
+ widgets?: UpdateDashboardWidgetRequestApi[]
+}
+
+export interface UpdateDashboardWidgetsBatchResponseApi {
+ /** Updated dashboard widget tiles in request order. */
+ tiles: DashboardTileApi[]
+}
+
/**
* * `add` - add
* * `remove` - remove
@@ -8779,6 +8918,18 @@ export const DashboardsWidgetsBatchCreateFormat = {
Txt: 'txt',
} as const
+export type DashboardsUpdateWidgetsBatchParams = {
+ format?: DashboardsUpdateWidgetsBatchFormat
+}
+
+export type DashboardsUpdateWidgetsBatchFormat =
+ (typeof DashboardsUpdateWidgetsBatchFormat)[keyof typeof DashboardsUpdateWidgetsBatchFormat]
+
+export const DashboardsUpdateWidgetsBatchFormat = {
+ Json: 'json',
+ Txt: 'txt',
+} as const
+
export type DashboardsBulkUpdateTagsCreateParams = {
format?: DashboardsBulkUpdateTagsCreateFormat
}
diff --git a/products/dashboards/frontend/generated/api.ts b/products/dashboards/frontend/generated/api.ts
index 3c57e493718b..b3ab3a73e757 100644
--- a/products/dashboards/frontend/generated/api.ts
+++ b/products/dashboards/frontend/generated/api.ts
@@ -40,6 +40,7 @@ import type {
DashboardsStreamTilesRetrieveParams,
DashboardsUpdateParams,
DashboardsUpdateTextTileCreateParams,
+ DashboardsUpdateWidgetsBatchParams,
DashboardsWidgetCatalogRetrieveParams,
DashboardsWidgetsBatchCreateParams,
DataColorThemeApi,
@@ -53,9 +54,11 @@ import type {
PatchedDataColorThemeApi,
PatchedMoveTileRequestApi,
PatchedPatchedDashboardOpenApiApi,
+ PatchedUpdateDashboardWidgetsBatchRequestOpenApiApi,
ReorderTilesRequestApi,
RunInsightsResponseApi,
RunWidgetsResponseApi,
+ UpdateDashboardWidgetsBatchResponseApi,
UpdateTextTileRequestApi,
WidgetCatalogResponseApi,
} from './api.schemas'
@@ -853,6 +856,53 @@ export const dashboardsWidgetsBatchCreate = async (
})
}
+export const getDashboardsUpdateWidgetsBatchUrl = (
+ projectId: string,
+ id: number,
+ params?: DashboardsUpdateWidgetsBatchParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : String(value))
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/projects/${projectId}/dashboards/${id}/widgets/batch_update/?${stringifiedParams}`
+ : `/api/projects/${projectId}/dashboards/${id}/widgets/batch_update/`
+}
+
+/**
+ * Update the settings of existing widgets in place, atomically — config, name, and description.
+ *
+ * Each entry targets a widget by its tile_id and reuses the same write path as the dashboard PATCH endpoint.
+ * The widget_type is immutable. This edits widget settings only (config, name, description); tile placement
+ * (layouts, show_description) is a dashboard concern — use the dashboard PATCH endpoint or reorder_tiles for
+ * that. All updates succeed or fail together. To add new widgets, use the widgets/batch POST endpoint; to
+ * remove one, use delete_tile.
+ */
+export const dashboardsUpdateWidgetsBatch = async (
+ projectId: string,
+ id: number,
+ patchedUpdateDashboardWidgetsBatchRequestOpenApiApi?: PatchedUpdateDashboardWidgetsBatchRequestOpenApiApi,
+ params?: DashboardsUpdateWidgetsBatchParams,
+ options?: RequestInit
+): Promise<UpdateDashboardWidgetsBatchResponseApi> => {
+ return apiMutator<UpdateDashboardWidgetsBatchResponseApi>(
+ getDashboardsUpdateWidgetsBatchUrl(projectId, id, params),
+ {
+ ...options,
+ method: 'PATCH',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(patchedUpdateDashboardWidgetsBatchRequestOpenApiApi),
+ }
+ )
+}
+
export const getDashboardsBulkUpdateTagsCreateUrl = (
projectId: string,
params?: DashboardsBulkUpdateTagsCreateParams
diff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.ts
index 214d086be79f..19862da1c01d 100644
--- a/products/dashboards/frontend/generated/api.zod.ts
+++ b/products/dashboards/frontend/generated/api.zod.ts
@@ -1539,6 +1539,496 @@ export const DashboardsWidgetsBatchCreateBody = /* @__PURE__ */ zod
})
.describe('OpenAPI-only batch-add schema with widget_type-discriminated config shapes for agents.')
+/**
+ * Update the settings of existing widgets in place, atomically — config, name, and description.
+ *
+ * Each entry targets a widget by its tile_id and reuses the same write path as the dashboard PATCH endpoint.
+ * The widget_type is immutable. This edits widget settings only (config, name, description); tile placement
+ * (layouts, show_description) is a dashboard concern — use the dashboard PATCH endpoint or reorder_tiles for
+ * that. All updates succeed or fail together. To add new widgets, use the widgets/batch POST endpoint; to
+ * remove one, use delete_tile.
+ */
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitDefault = 25
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitMax = 50
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitDefault = 10
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitMax = 25
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderByDefault = `occurrences`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderDirectionDefault = `DESC`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneStatusDefault = `active`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitDefault = 10
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitMax = 25
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderByDefault = `start_time`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderDirectionDefault = `DESC`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitDefault = 10
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitMax = 25
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderByDefault = `created_at`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderDirectionDefault = `DESC`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneStatusDefault = `all`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFiveNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsMax = 10
+
+export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
+ .object({
+ widgets: zod
+ .array(
+ zod.union([
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemOneNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['activity_events_list']),
+ config: zod
+ .object({
+ dateRange: zod
+ .union([
+ zod.object({
+ date_from: zod
+ .union([
+ zod.enum([
+ '-1M',
+ '-30M',
+ '-1h',
+ '-3h',
+ '-24h',
+ '-7d',
+ '-14d',
+ '-30d',
+ '-90d',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ zod.null(),
+ ])
+ .optional(),
+ filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
+ widgetFilters: zod
+ .union([
+ zod.record(
+ zod.string(),
+ zod.object({
+ filterId: zod.string().min(1),
+ propertyName: zod.string().min(1),
+ optionId: zod.string().min(1),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitDefault)
+ .describe('Maximum number of events to return.'),
+ })
+ .optional()
+ .describe('New configuration for the recent events widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['error_tracking_list']),
+ config: zod
+ .object({
+ dateRange: zod
+ .union([
+ zod.object({
+ date_from: zod
+ .union([
+ zod.enum([
+ '-1M',
+ '-30M',
+ '-1h',
+ '-3h',
+ '-24h',
+ '-7d',
+ '-14d',
+ '-30d',
+ '-90d',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ zod.null(),
+ ])
+ .optional(),
+ filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
+ widgetFilters: zod
+ .union([
+ zod.record(
+ zod.string(),
+ zod.object({
+ filterId: zod.string().min(1),
+ propertyName: zod.string().min(1),
+ optionId: zod.string().min(1),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitDefault)
+ .describe('Maximum number of issues to return.'),
+ orderBy: zod
+ .enum(['last_seen', 'first_seen', 'occurrences', 'users', 'sessions'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderByDefault)
+ .describe('Issue ranking column.'),
+ orderDirection: zod
+ .enum(['ASC', 'DESC'])
+ .default(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderDirectionDefault
+ )
+ .describe('Sort direction for orderBy.'),
+ status: zod
+ .enum(['archived', 'active', 'resolved', 'pending_release', 'suppressed', 'all'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneStatusDefault)
+ .describe('Issue status filter.'),
+ assignee: zod
+ .union([
+ zod.object({
+ id: zod.union([zod.string(), zod.number()]),
+ type: zod.enum(['user', 'role']),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Filter by assignee ({type: user|role, id}). Omit for any assignee.'),
+ })
+ .optional()
+ .describe('New configuration for the top issues widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['session_replay_list']),
+ config: zod
+ .object({
+ dateRange: zod
+ .union([
+ zod.object({
+ date_from: zod
+ .union([
+ zod.enum([
+ '-1M',
+ '-30M',
+ '-1h',
+ '-3h',
+ '-24h',
+ '-7d',
+ '-14d',
+ '-30d',
+ '-90d',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ zod.null(),
+ ])
+ .optional(),
+ filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
+ widgetFilters: zod
+ .union([
+ zod.record(
+ zod.string(),
+ zod.object({
+ filterId: zod.string().min(1),
+ propertyName: zod.string().min(1),
+ optionId: zod.string().min(1),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitDefault)
+ .describe('Maximum number of recordings to return.'),
+ orderBy: zod
+ .enum([
+ 'start_time',
+ 'activity_score',
+ 'recording_duration',
+ 'duration',
+ 'click_count',
+ 'console_error_count',
+ ])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderByDefault)
+ .describe('Recording ranking column.'),
+ orderDirection: zod
+ .enum(['ASC', 'DESC'])
+ .default(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderDirectionDefault
+ )
+ .describe('Sort direction for orderBy.'),
+ savedFilterId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ ),
+ })
+ .optional()
+ .describe('New configuration for the recent recordings widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['experiments_list']),
+ config: zod
+ .object({
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitDefault)
+ .describe('Maximum number of experiments to return.'),
+ orderBy: zod
+ .enum(['created_at', 'name', 'start_date'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderByDefault)
+ .describe('Experiment list sort column.'),
+ orderDirection: zod
+ .enum(['ASC', 'DESC'])
+ .default(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderDirectionDefault
+ )
+ .describe('Sort direction for orderBy.'),
+ status: zod
+ .enum(['draft', 'running', 'paused', 'stopped', 'all'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneStatusDefault)
+ .describe('Experiment status filter.'),
+ createdBy: zod
+ .union([zod.number(), zod.null()])
+ .optional()
+ .describe('Filter by creator (user id). Omit for any creator.'),
+ })
+ .optional()
+ .describe('New configuration for the experiments list widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemFiveNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['experiment_results']),
+ config: zod
+ .object({
+ experimentId: zod
+ .union([zod.number(), zod.null()])
+ .optional()
+ .describe(
+ 'Experiment to show results for. Null until the user picks one in the widget settings.'
+ ),
+ })
+ .optional()
+ .describe('New configuration for the experiment results widget. Omit to leave unchanged.'),
+ }),
+ ])
+ )
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsMax)
+ .optional()
+ .describe(
+ 'Widget tiles to update atomically, each identified by its tile_id. config shape is per widget_type; see dashboard-widget-catalog-list for per-type config_schema (1–10 per request).'
+ ),
+ })
+ .describe('OpenAPI-only batch-update schema with widget_type-discriminated config shapes for agents.')
+
/**
* Bulk update tags on multiple objects.
*
diff --git a/products/dashboards/mcp/tools.yaml b/products/dashboards/mcp/tools.yaml
index 63254c214e0b..2bba8d9326ac 100644
--- a/products/dashboards/mcp/tools.yaml
+++ b/products/dashboards/mcp/tools.yaml
@@ -282,11 +282,12 @@ tools:
title: Update dashboard
description: >
Update an existing dashboard by ID. Can update name, description, pinned status, tags, filters, and
- restriction level. To update widget tiles, pass `tiles` with each tile's `id` and nested `widget.id` plus
- fields to change (`config`, `name`, `description`) from dashboard-get — the same PATCH path the UI uses.
- There is no separate PATCH .../widgets/:tile_id/ endpoint. To add new widget tiles to this dashboard, use
- dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use
- dashboard-insights-run to fetch the actual data for each insight.
+ restriction level, and widget tile placement (layouts, show_description). To change a widget's own settings
+ (config, name, description), prefer dashboard-widgets-batch-update, which takes just a tile_id per widget.
+ You can also update widget tiles here by passing `tiles` with each tile's `id` and nested `widget.id` plus
+ fields to change (`config`, `name`, `description`) from dashboard-get — the same PATCH path the UI uses. To
+ add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit
+ insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.
exclude_params:
- creation_mode
- effective_restriction_level
@@ -389,7 +390,32 @@ tools:
array of payloads (widget_type, config, optional name, description, layouts). Config shape is per
widget_type (see catalog hints); widgetFilters when supported is a map of filter id to property filter
entries. For a single tile, pass a one-element `widgets` array. Tiles stack at the bottom when layouts are
- omitted. Returns all created tiles; use dashboard-widgets-run to fetch live data.
+ omitted. Returns all created tiles; use dashboard-widgets-run to fetch live data. This only adds new tiles —
+ to edit existing widget tiles, use dashboard-widgets-batch-update (no delete-and-re-add needed).
+ param_overrides:
+ id:
+ cast: string-int
+ feature_flag: dashboard-widgets
+ dashboard-widgets-batch-update:
+ operation: dashboards_update_widgets_batch
+ enabled: true
+ scopes:
+ - dashboard:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ enrich_url: '{params.id}'
+ title: Update dashboard widget settings
+ description: >
+ Update the settings of existing widgets in place atomically (1–10), without delete-and-re-add. Edits widget
+ settings only — `config`, `name`, and `description`. Pass `widgets` as an array of payloads, each identified
+ by its DashboardTile `tile_id` (use dashboard-get to look up widget tile IDs) plus the settings to change.
+ Only the fields you provide per widget are updated; omitted fields are left unchanged. Optionally pass
+ `widget_type` to get the typed config shape; widget_type is immutable. Config shape is per widget_type — see
+ dashboard-widget-catalog-list. All updates succeed or fail together. Tile placement (layout,
+ show_description) is not changed here — use dashboard-update or dashboard-reorder-tiles for that. To add new
+ widgets, use dashboard-widgets-batch-add; to remove one, use dashboard-delete-tile.
param_overrides:
id:
cast: string-int
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 524df648f870..28cb89f845d2 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -1813,7 +1813,7 @@
}
},
"dashboard-update": {
- "description": "Update an existing dashboard by ID. Can update name, description, pinned status, tags, filters, and restriction level. To update widget tiles, pass `tiles` with each tile's `id` and nested `widget.id` plus fields to change (`config`, `name`, `description`) from dashboard-get — the same PATCH path the UI uses. There is no separate PATCH .../widgets/:tile_id/ endpoint. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
+ "description": "Update an existing dashboard by ID. Can update name, description, pinned status, tags, filters, and restriction level, and widget tile placement (layouts, show_description). To change a widget's own settings (config, name, description), prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. You can also update widget tiles here by passing `tiles` with each tile's `id` and nested `widget.id` plus fields to change (`config`, `name`, `description`) from dashboard-get — the same PATCH path the UI uses. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
"category": "Dashboards",
"feature": "dashboards",
"summary": "Update dashboard",
@@ -1855,7 +1855,7 @@
}
},
"dashboard-widgets-batch-add": {
- "description": "Add widget tiles to a dashboard atomically via POST .../widgets/batch/ (1–10 tiles). Call dashboard-widget-catalog-list first for valid widget_type values and config_schema. Pass `widgets` as an array of payloads (widget_type, config, optional name, description, layouts). Config shape is per widget_type (see catalog hints); widgetFilters when supported is a map of filter id to property filter entries. For a single tile, pass a one-element `widgets` array. Tiles stack at the bottom when layouts are omitted. Returns all created tiles; use dashboard-widgets-run to fetch live data.",
+ "description": "Add widget tiles to a dashboard atomically via POST .../widgets/batch/ (1–10 tiles). Call dashboard-widget-catalog-list first for valid widget_type values and config_schema. Pass `widgets` as an array of payloads (widget_type, config, optional name, description, layouts). Config shape is per widget_type (see catalog hints); widgetFilters when supported is a map of filter id to property filter entries. For a single tile, pass a one-element `widgets` array. Tiles stack at the bottom when layouts are omitted. Returns all created tiles; use dashboard-widgets-run to fetch live data. This only adds new tiles — to edit existing widget tiles, use dashboard-widgets-batch-update (no delete-and-re-add needed).",
"category": "Dashboards",
"feature": "dashboards",
"summary": "Add dashboard widgets",
@@ -1869,6 +1869,21 @@
},
"feature_flag": "dashboard-widgets"
},
+ "dashboard-widgets-batch-update": {
+ "description": "Update the settings of existing widgets in place atomically (1–10), without delete-and-re-add. Edits widget settings only — `config`, `name`, and `description`. Pass `widgets` as an array of payloads, each identified by its DashboardTile `tile_id` (use dashboard-get to look up widget tile IDs) plus the settings to change. Only the fields you provide per widget are updated; omitted fields are left unchanged. Optionally pass `widget_type` to get the typed config shape; widget_type is immutable. Config shape is per widget_type — see dashboard-widget-catalog-list. All updates succeed or fail together. Tile placement (layout, show_description) is not changed here — use dashboard-update or dashboard-reorder-tiles for that. To add new widgets, use dashboard-widgets-batch-add; to remove one, use dashboard-delete-tile.",
+ "category": "Dashboards",
+ "feature": "dashboards",
+ "summary": "Update dashboard widget settings",
+ "title": "Update dashboard widget settings",
+ "required_scopes": ["dashboard:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "dashboard-widgets"
+ },
"dashboard-widgets-run": {
"description": "Run live queries for dashboard widget tiles and return results. Requires the dashboard-widgets feature flag. Call dashboard-get first to find widget tile IDs (tiles with a widget field). Pass tile_ids as a comma-separated list. Each successful result is a widget-type-specific payload (see run_widgets OpenAPI response and dashboard-widget-catalog-list config_schema). Returns per-tile errors when the caller lacks product access for a widget type (see required_product_access on dashboard-widget-catalog-list). Not available on public/shared dashboard views.",
"category": "Dashboards",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index af43f3f43e00..3257d53ad4d1 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -1843,7 +1843,7 @@
}
},
"dashboard-update": {
- "description": "Update an existing dashboard by ID. Can update name, description, pinned status, tags, filters, and restriction level. To update widget tiles, pass `tiles` with each tile's `id` and nested `widget.id` plus fields to change (`config`, `name`, `description`) from dashboard-get — the same PATCH path the UI uses. There is no separate PATCH .../widgets/:tile_id/ endpoint. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
+ "description": "Update an existing dashboard by ID. Can update name, description, pinned status, tags, filters, and restriction level, and widget tile placement (layouts, show_description). To change a widget's own settings (config, name, description), prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. You can also update widget tiles here by passing `tiles` with each tile's `id` and nested `widget.id` plus fields to change (`config`, `name`, `description`) from dashboard-get — the same PATCH path the UI uses. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
"category": "Dashboards",
"feature": "dashboards",
"summary": "Update dashboard",
@@ -1885,7 +1885,7 @@
}
},
"dashboard-widgets-batch-add": {
- "description": "Add widget tiles to a dashboard atomically via POST .../widgets/batch/ (1–10 tiles). Call dashboard-widget-catalog-list first for valid widget_type values and config_schema. Pass `widgets` as an array of payloads (widget_type, config, optional name, description, layouts). Config shape is per widget_type (see catalog hints); widgetFilters when supported is a map of filter id to property filter entries. For a single tile, pass a one-element `widgets` array. Tiles stack at the bottom when layouts are omitted. Returns all created tiles; use dashboard-widgets-run to fetch live data.",
+ "description": "Add widget tiles to a dashboard atomically via POST .../widgets/batch/ (1–10 tiles). Call dashboard-widget-catalog-list first for valid widget_type values and config_schema. Pass `widgets` as an array of payloads (widget_type, config, optional name, description, layouts). Config shape is per widget_type (see catalog hints); widgetFilters when supported is a map of filter id to property filter entries. For a single tile, pass a one-element `widgets` array. Tiles stack at the bottom when layouts are omitted. Returns all created tiles; use dashboard-widgets-run to fetch live data. This only adds new tiles — to edit existing widget tiles, use dashboard-widgets-batch-update (no delete-and-re-add needed).",
"category": "Dashboards",
"feature": "dashboards",
"summary": "Add dashboard widgets",
@@ -1899,6 +1899,21 @@
},
"feature_flag": "dashboard-widgets"
},
+ "dashboard-widgets-batch-update": {
+ "description": "Update the settings of existing widgets in place atomically (1–10), without delete-and-re-add. Edits widget settings only — `config`, `name`, and `description`. Pass `widgets` as an array of payloads, each identified by its DashboardTile `tile_id` (use dashboard-get to look up widget tile IDs) plus the settings to change. Only the fields you provide per widget are updated; omitted fields are left unchanged. Optionally pass `widget_type` to get the typed config shape; widget_type is immutable. Config shape is per widget_type — see dashboard-widget-catalog-list. All updates succeed or fail together. Tile placement (layout, show_description) is not changed here — use dashboard-update or dashboard-reorder-tiles for that. To add new widgets, use dashboard-widgets-batch-add; to remove one, use dashboard-delete-tile.",
+ "category": "Dashboards",
+ "feature": "dashboards",
+ "summary": "Update dashboard widget settings",
+ "title": "Update dashboard widget settings",
+ "required_scopes": ["dashboard:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "dashboard-widgets"
+ },
"dashboard-widgets-run": {
"description": "Run live queries for dashboard widget tiles and return results. Requires the dashboard-widgets feature flag. Call dashboard-get first to find widget tile IDs (tiles with a widget field). Pass tile_ids as a comma-separated list. Each successful result is a widget-type-specific payload (see run_widgets OpenAPI response and dashboard-widget-catalog-list config_schema). Returns per-tile errors when the caller lacks product access for a widget type (see required_product_access on dashboard-widget-catalog-list). Not available on public/shared dashboard views.",
"category": "Dashboards",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 4a85ab91b2cd..fbf5363b78ff 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -1858,6 +1858,29 @@ export namespace Schemas {
ActivityEventsList: 'activity_events_list',
} as const;
+ export type ActivityEventsListWidgetUpdateRequestOpenApiWidgetType = typeof ActivityEventsListWidgetUpdateRequestOpenApiWidgetType[keyof typeof ActivityEventsListWidgetUpdateRequestOpenApiWidgetType];
+
+
+ export const ActivityEventsListWidgetUpdateRequestOpenApiWidgetType = {
+ ActivityEventsList: 'activity_events_list',
+ } as const;
+
+ export interface ActivityEventsListWidgetUpdateRequestOpenApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number;
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null;
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string;
+ widget_type: ActivityEventsListWidgetUpdateRequestOpenApiWidgetType;
+ /** New configuration for the recent events widget. Omit to leave unchanged. */
+ config?: ActivityEventsListWidgetConfig;
+ }
+
export interface ActivityLog {
readonly id: string;
user: UserBasic;
@@ -19516,6 +19539,29 @@ export namespace Schemas {
ErrorTrackingList: 'error_tracking_list',
} as const;
+ export type ErrorTrackingListWidgetUpdateRequestOpenApiWidgetType = typeof ErrorTrackingListWidgetUpdateRequestOpenApiWidgetType[keyof typeof ErrorTrackingListWidgetUpdateRequestOpenApiWidgetType];
+
+
+ export const ErrorTrackingListWidgetUpdateRequestOpenApiWidgetType = {
+ ErrorTrackingList: 'error_tracking_list',
+ } as const;
+
+ export interface ErrorTrackingListWidgetUpdateRequestOpenApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number;
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null;
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string;
+ widget_type: ErrorTrackingListWidgetUpdateRequestOpenApiWidgetType;
+ /** New configuration for the top issues widget. Omit to leave unchanged. */
+ config?: ErrorTrackingListWidgetConfig;
+ }
+
export interface ErrorTrackingRecommendation {
/** Recommendation UUID. */
id: string;
@@ -21277,6 +21323,29 @@ export namespace Schemas {
ExperimentResults: 'experiment_results',
} as const;
+ export type ExperimentResultsWidgetUpdateRequestOpenApiWidgetType = typeof ExperimentResultsWidgetUpdateRequestOpenApiWidgetType[keyof typeof ExperimentResultsWidgetUpdateRequestOpenApiWidgetType];
+
+
+ export const ExperimentResultsWidgetUpdateRequestOpenApiWidgetType = {
+ ExperimentResults: 'experiment_results',
+ } as const;
+
+ export interface ExperimentResultsWidgetUpdateRequestOpenApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number;
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null;
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string;
+ widget_type: ExperimentResultsWidgetUpdateRequestOpenApiWidgetType;
+ /** New configuration for the experiment results widget. Omit to leave unchanged. */
+ config?: ExperimentResultsWidgetConfig;
+ }
+
/**
* Mixin for serializers to add user access control fields
*/
@@ -21335,6 +21404,29 @@ export namespace Schemas {
ExperimentsList: 'experiments_list',
} as const;
+ export type ExperimentsListWidgetUpdateRequestOpenApiWidgetType = typeof ExperimentsListWidgetUpdateRequestOpenApiWidgetType[keyof typeof ExperimentsListWidgetUpdateRequestOpenApiWidgetType];
+
+
+ export const ExperimentsListWidgetUpdateRequestOpenApiWidgetType = {
+ ExperimentsList: 'experiments_list',
+ } as const;
+
+ export interface ExperimentsListWidgetUpdateRequestOpenApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number;
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null;
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string;
+ widget_type: ExperimentsListWidgetUpdateRequestOpenApiWidgetType;
+ /** New configuration for the experiments list widget. Omit to leave unchanged. */
+ config?: ExperimentsListWidgetConfig;
+ }
+
export interface ExplainRequest {
/** UUID of the log entry to explain */
uuid: string;
@@ -40780,6 +40872,43 @@ export namespace Schemas {
queue_id?: string | null;
}
+ export type SessionReplayListWidgetUpdateRequestOpenApiWidgetType = typeof SessionReplayListWidgetUpdateRequestOpenApiWidgetType[keyof typeof SessionReplayListWidgetUpdateRequestOpenApiWidgetType];
+
+
+ export const SessionReplayListWidgetUpdateRequestOpenApiWidgetType = {
+ SessionReplayList: 'session_replay_list',
+ } as const;
+
+ export interface SessionReplayListWidgetUpdateRequestOpenApi {
+ /** ID of the widget tile to update. Use dashboard-get to look up widget tile IDs. */
+ tile_id: number;
+ /**
+ * New display name for the widget. Empty string or null clears it; omit to leave unchanged.
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null;
+ /** New markdown description for the widget. Omit to leave unchanged. */
+ description?: string;
+ widget_type: SessionReplayListWidgetUpdateRequestOpenApiWidgetType;
+ /** New configuration for the recent recordings widget. Omit to leave unchanged. */
+ config?: SessionReplayListWidgetConfig;
+ }
+
+ export type UpdateDashboardWidgetRequest = ActivityEventsListWidgetUpdateRequestOpenApi | ErrorTrackingListWidgetUpdateRequestOpenApi | SessionReplayListWidgetUpdateRequestOpenApi | ExperimentsListWidgetUpdateRequestOpenApi | ExperimentResultsWidgetUpdateRequestOpenApi;
+
+ /**
+ * OpenAPI-only batch-update schema with widget_type-discriminated config shapes for agents.
+ */
+ export interface PatchedUpdateDashboardWidgetsBatchRequestOpenApi {
+ /**
+ * Widget tiles to update atomically, each identified by its tile_id. config shape is per widget_type; see dashboard-widget-catalog-list for per-type config_schema (1–10 per request).
+ * @minItems 1
+ * @maxItems 10
+ */
+ widgets?: UpdateDashboardWidgetRequest[];
+ }
+
/**
* @nullable
*/
@@ -50314,6 +50443,11 @@ export namespace Schemas {
target_language?: string;
}
+ export interface UpdateDashboardWidgetsBatchResponse {
+ /** Updated dashboard widget tiles in request order. */
+ tiles: DashboardTile[];
+ }
+
export interface UpdateTextTileRequest {
/** ID of the dashboard tile to update. Use dashboard-get to look up tile IDs. */
tile_id: number;
@@ -52711,6 +52845,18 @@ export namespace Schemas {
Txt: 'txt',
} as const;
+ export type EnvironmentsDashboardsUpdateWidgetsBatchParams = {
+ format?: EnvironmentsDashboardsUpdateWidgetsBatchFormat;
+ };
+
+ export type EnvironmentsDashboardsUpdateWidgetsBatchFormat = typeof EnvironmentsDashboardsUpdateWidgetsBatchFormat[keyof typeof EnvironmentsDashboardsUpdateWidgetsBatchFormat];
+
+
+ export const EnvironmentsDashboardsUpdateWidgetsBatchFormat = {
+ Json: 'json',
+ Txt: 'txt',
+ } as const;
+
export type EnvironmentsDashboardsBulkUpdateTagsCreateParams = {
format?: EnvironmentsDashboardsBulkUpdateTagsCreateFormat;
};
@@ -58499,6 +58645,18 @@ export namespace Schemas {
Txt: 'txt',
} as const;
+ export type DashboardsUpdateWidgetsBatchParams = {
+ format?: DashboardsUpdateWidgetsBatchFormat;
+ };
+
+ export type DashboardsUpdateWidgetsBatchFormat = typeof DashboardsUpdateWidgetsBatchFormat[keyof typeof DashboardsUpdateWidgetsBatchFormat];
+
+
+ export const DashboardsUpdateWidgetsBatchFormat = {
+ Json: 'json',
+ Txt: 'txt',
+ } as const;
+
export type DashboardsBulkUpdateTagsCreateParams = {
format?: DashboardsBulkUpdateTagsCreateFormat;
};
diff --git a/services/mcp/src/generated/dashboards/api.ts b/services/mcp/src/generated/dashboards/api.ts
index e88330c05f9d..d9ac92744cf4 100644
--- a/services/mcp/src/generated/dashboards/api.ts
+++ b/services/mcp/src/generated/dashboards/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 15 enabled ops
+ * PostHog API - MCP 16 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -1593,6 +1593,509 @@ export const DashboardsWidgetsBatchCreateBody = /* @__PURE__ */ zod
})
.describe('OpenAPI-only batch-add schema with widget_type-discriminated config shapes for agents.')
+/**
+ * Update the settings of existing widgets in place, atomically — config, name, and description.
+ *
+ * Each entry targets a widget by its tile_id and reuses the same write path as the dashboard PATCH endpoint.
+ * The widget_type is immutable. This edits widget settings only (config, name, description); tile placement
+ * (layouts, show_description) is a dashboard concern — use the dashboard PATCH endpoint or reorder_tiles for
+ * that. All updates succeed or fail together. To add new widgets, use the widgets/batch POST endpoint; to
+ * remove one, use delete_tile.
+ */
+export const DashboardsUpdateWidgetsBatchParams = /* @__PURE__ */ zod.object({
+ id: zod.number().describe('A unique integer value identifying this dashboard.'),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."
+ ),
+})
+
+export const DashboardsUpdateWidgetsBatchQueryParams = /* @__PURE__ */ zod.object({
+ format: zod.enum(['json', 'txt']).optional(),
+})
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitDefault = 25
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitMax = 50
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitDefault = 10
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitMax = 25
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderByDefault = `occurrences`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderDirectionDefault = `DESC`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneStatusDefault = `active`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitDefault = 10
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitMax = 25
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderByDefault = `start_time`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderDirectionDefault = `DESC`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitDefault = 10
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitMax = 25
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderByDefault = `created_at`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderDirectionDefault = `DESC`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneStatusDefault = `all`
+export const dashboardsUpdateWidgetsBatchBodyWidgetsItemFiveNameMax = 400
+
+export const dashboardsUpdateWidgetsBatchBodyWidgetsMax = 10
+
+export const DashboardsUpdateWidgetsBatchBody = /* @__PURE__ */ zod
+ .object({
+ widgets: zod
+ .array(
+ zod.union([
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemOneNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['activity_events_list']),
+ config: zod
+ .object({
+ dateRange: zod
+ .union([
+ zod.object({
+ date_from: zod
+ .union([
+ zod.enum([
+ '-1M',
+ '-30M',
+ '-1h',
+ '-3h',
+ '-24h',
+ '-7d',
+ '-14d',
+ '-30d',
+ '-90d',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ zod.null(),
+ ])
+ .optional(),
+ filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
+ widgetFilters: zod
+ .union([
+ zod.record(
+ zod.string(),
+ zod.object({
+ filterId: zod.string().min(1),
+ propertyName: zod.string().min(1),
+ optionId: zod.string().min(1),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemOneConfigOneLimitDefault)
+ .describe('Maximum number of events to return.'),
+ })
+ .optional()
+ .describe('New configuration for the recent events widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['error_tracking_list']),
+ config: zod
+ .object({
+ dateRange: zod
+ .union([
+ zod.object({
+ date_from: zod
+ .union([
+ zod.enum([
+ '-1M',
+ '-30M',
+ '-1h',
+ '-3h',
+ '-24h',
+ '-7d',
+ '-14d',
+ '-30d',
+ '-90d',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ zod.null(),
+ ])
+ .optional(),
+ filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
+ widgetFilters: zod
+ .union([
+ zod.record(
+ zod.string(),
+ zod.object({
+ filterId: zod.string().min(1),
+ propertyName: zod.string().min(1),
+ optionId: zod.string().min(1),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneLimitDefault)
+ .describe('Maximum number of issues to return.'),
+ orderBy: zod
+ .enum(['last_seen', 'first_seen', 'occurrences', 'users', 'sessions'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderByDefault)
+ .describe('Issue ranking column.'),
+ orderDirection: zod
+ .enum(['ASC', 'DESC'])
+ .default(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneOrderDirectionDefault
+ )
+ .describe('Sort direction for orderBy.'),
+ status: zod
+ .enum(['archived', 'active', 'resolved', 'pending_release', 'suppressed', 'all'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemTwoConfigOneStatusDefault)
+ .describe('Issue status filter.'),
+ assignee: zod
+ .union([
+ zod.object({
+ id: zod.union([zod.string(), zod.number()]),
+ type: zod.enum(['user', 'role']),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Filter by assignee ({type: user|role, id}). Omit for any assignee.'),
+ })
+ .optional()
+ .describe('New configuration for the top issues widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['session_replay_list']),
+ config: zod
+ .object({
+ dateRange: zod
+ .union([
+ zod.object({
+ date_from: zod
+ .union([
+ zod.enum([
+ '-1M',
+ '-30M',
+ '-1h',
+ '-3h',
+ '-24h',
+ '-7d',
+ '-14d',
+ '-30d',
+ '-90d',
+ ]),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ zod.null(),
+ ])
+ .optional(),
+ filterTestAccounts: zod.union([zod.boolean(), zod.null()]).optional(),
+ widgetFilters: zod
+ .union([
+ zod.record(
+ zod.string(),
+ zod.object({
+ filterId: zod.string().min(1),
+ propertyName: zod.string().min(1),
+ optionId: zod.string().min(1),
+ operator: zod.enum([
+ 'exact',
+ 'is_not',
+ 'icontains',
+ 'not_icontains',
+ 'regex',
+ 'not_regex',
+ 'gt',
+ 'gte',
+ 'lt',
+ 'lte',
+ 'is_set',
+ 'is_not_set',
+ 'is_date_exact',
+ 'is_date_before',
+ 'is_date_after',
+ 'between',
+ 'not_between',
+ 'min',
+ 'max',
+ 'in',
+ 'not_in',
+ 'is_cleaned_path_exact',
+ 'flag_evaluates_to',
+ 'semver_eq',
+ 'semver_neq',
+ 'semver_gt',
+ 'semver_gte',
+ 'semver_lt',
+ 'semver_lte',
+ 'semver_tilde',
+ 'semver_caret',
+ 'semver_wildcard',
+ 'icontains_multi',
+ 'not_icontains_multi',
+ ]),
+ value: zod
+ .union([zod.string(), zod.array(zod.string()), zod.null()])
+ .optional(),
+ })
+ ),
+ zod.null(),
+ ])
+ .optional(),
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneLimitDefault)
+ .describe('Maximum number of recordings to return.'),
+ orderBy: zod
+ .enum([
+ 'start_time',
+ 'activity_score',
+ 'recording_duration',
+ 'duration',
+ 'click_count',
+ 'console_error_count',
+ ])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderByDefault)
+ .describe('Recording ranking column.'),
+ orderDirection: zod
+ .enum(['ASC', 'DESC'])
+ .default(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemThreeConfigOneOrderDirectionDefault
+ )
+ .describe('Sort direction for orderBy.'),
+ savedFilterId: zod
+ .union([zod.string(), zod.null()])
+ .optional()
+ .describe(
+ 'short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply.'
+ ),
+ })
+ .optional()
+ .describe('New configuration for the recent recordings widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['experiments_list']),
+ config: zod
+ .object({
+ limit: zod
+ .number()
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitMax)
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneLimitDefault)
+ .describe('Maximum number of experiments to return.'),
+ orderBy: zod
+ .enum(['created_at', 'name', 'start_date'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderByDefault)
+ .describe('Experiment list sort column.'),
+ orderDirection: zod
+ .enum(['ASC', 'DESC'])
+ .default(
+ dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneOrderDirectionDefault
+ )
+ .describe('Sort direction for orderBy.'),
+ status: zod
+ .enum(['draft', 'running', 'paused', 'stopped', 'all'])
+ .default(dashboardsUpdateWidgetsBatchBodyWidgetsItemFourConfigOneStatusDefault)
+ .describe('Experiment status filter.'),
+ createdBy: zod
+ .union([zod.number(), zod.null()])
+ .optional()
+ .describe('Filter by creator (user id). Omit for any creator.'),
+ })
+ .optional()
+ .describe('New configuration for the experiments list widget. Omit to leave unchanged.'),
+ }),
+ zod.object({
+ tile_id: zod
+ .number()
+ .describe('ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.'),
+ name: zod
+ .string()
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsItemFiveNameMax)
+ .nullish()
+ .describe(
+ 'New display name for the widget. Empty string or null clears it; omit to leave unchanged.'
+ ),
+ description: zod
+ .string()
+ .optional()
+ .describe('New markdown description for the widget. Omit to leave unchanged.'),
+ widget_type: zod.enum(['experiment_results']),
+ config: zod
+ .object({
+ experimentId: zod
+ .union([zod.number(), zod.null()])
+ .optional()
+ .describe(
+ 'Experiment to show results for. Null until the user picks one in the widget settings.'
+ ),
+ })
+ .optional()
+ .describe('New configuration for the experiment results widget. Omit to leave unchanged.'),
+ }),
+ ])
+ )
+ .min(1)
+ .max(dashboardsUpdateWidgetsBatchBodyWidgetsMax)
+ .optional()
+ .describe(
+ 'Widget tiles to update atomically, each identified by its tile_id. config shape is per widget_type; see dashboard-widget-catalog-list for per-type config_schema (1–10 per request).'
+ ),
+ })
+ .describe('OpenAPI-only batch-update schema with widget_type-discriminated config shapes for agents.')
+
/**
* List registered dashboard widget types and per-type config_schema documentation for agents.
*/
diff --git a/services/mcp/src/tools/generated/dashboards.ts b/services/mcp/src/tools/generated/dashboards.ts
index 3bbd14a14aca..7b370e653b4f 100644
--- a/services/mcp/src/tools/generated/dashboards.ts
+++ b/services/mcp/src/tools/generated/dashboards.ts
@@ -26,6 +26,8 @@ import {
DashboardsRunWidgetsRetrieveQueryParams,
DashboardsUpdateTextTileCreateBody,
DashboardsUpdateTextTileCreateParams,
+ DashboardsUpdateWidgetsBatchBody,
+ DashboardsUpdateWidgetsBatchParams,
DashboardsWidgetsBatchCreateBody,
DashboardsWidgetsBatchCreateParams,
} from '@/generated/dashboards/api'
@@ -528,6 +530,31 @@ const dashboardWidgetsBatchAdd = (): ToolBase<
},
})
+const DashboardWidgetsBatchUpdateSchema = DashboardsUpdateWidgetsBatchParams.omit({ project_id: true })
+ .extend(DashboardsUpdateWidgetsBatchBody.shape)
+ .extend({ id: z.preprocess(castStringToInt, DashboardsUpdateWidgetsBatchParams.shape['id']) })
+
+const dashboardWidgetsBatchUpdate = (): ToolBase<
+ typeof DashboardWidgetsBatchUpdateSchema,
+ WithPostHogUrl<Schemas.UpdateDashboardWidgetsBatchResponse>
+> => ({
+ name: 'dashboard-widgets-batch-update',
+ schema: DashboardWidgetsBatchUpdateSchema,
+ handler: async (context: Context, params: z.infer<typeof DashboardWidgetsBatchUpdateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.widgets !== undefined) {
+ body['widgets'] = params.widgets
+ }
+ const result = await context.api.request<Schemas.UpdateDashboardWidgetsBatchResponse>({
+ method: 'PATCH',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/dashboards/${encodeURIComponent(String(params.id))}/widgets/batch_update/`,
+ body,
+ })
+ return await withPostHogUrl(context, result, `/dashboard/${params.id}`)
+ },
+})
+
const DashboardWidgetsRunSchema = DashboardsRunWidgetsRetrieveParams.omit({ project_id: true })
.extend(DashboardsRunWidgetsRetrieveQueryParams.omit({ format: true }).shape)
.extend({ id: z.preprocess(castStringToInt, DashboardsRunWidgetsRetrieveParams.shape['id']) })
@@ -628,6 +655,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'dashboard-update-text-tile': dashboardUpdateTextTile,
'dashboard-widget-catalog-list': dashboardWidgetCatalogList,
'dashboard-widgets-batch-add': dashboardWidgetsBatchAdd,
+ 'dashboard-widgets-batch-update': dashboardWidgetsBatchUpdate,
'dashboard-widgets-run': dashboardWidgetsRun,
'dashboards-get-all': dashboardsGetAll,
'dashboards-move-tile-partial-update': dashboardsMoveTilePartialUpdate,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json
new file mode 100644
index 000000000000..39765a9deec6
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-widgets-batch-update.json
@@ -0,0 +1,739 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A unique integer value identifying this dashboard.",
+ "type": "number"
+ },
+ "widgets": {
+ "description": "Widget tiles to update atomically, each identified by its tile_id. config shape is per widget_type; see dashboard-widget-catalog-list for per-type config_schema (1–10 per request).",
+ "items": {
+ "anyOf": [
+ {
+ "properties": {
+ "config": {
+ "description": "New configuration for the recent events widget. Omit to leave unchanged.",
+ "properties": {
+ "dateRange": {
+ "anyOf": [
+ {
+ "properties": {
+ "date_from": {
+ "anyOf": [
+ {
+ "enum": [
+ "-1M",
+ "-30M",
+ "-1h",
+ "-3h",
+ "-24h",
+ "-7d",
+ "-14d",
+ "-30d",
+ "-90d"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "filterTestAccounts": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "limit": {
+ "default": 25,
+ "description": "Maximum number of events to return.",
+ "maximum": 50,
+ "minimum": 1,
+ "type": "number"
+ },
+ "widgetFilters": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "properties": {
+ "filterId": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "operator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex",
+ "gt",
+ "gte",
+ "lt",
+ "lte",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after",
+ "between",
+ "not_between",
+ "min",
+ "max",
+ "in",
+ "not_in",
+ "is_cleaned_path_exact",
+ "flag_evaluates_to",
+ "semver_eq",
+ "semver_neq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_tilde",
+ "semver_caret",
+ "semver_wildcard",
+ "icontains_multi",
+ "not_icontains_multi"
+ ],
+ "type": "string"
+ },
+ "optionId": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "propertyName": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["filterId", "propertyName", "optionId", "operator"],
+ "type": "object"
+ },
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "description": {
+ "description": "New markdown description for the widget. Omit to leave unchanged.",
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "New display name for the widget. Empty string or null clears it; omit to leave unchanged."
+ },
+ "tile_id": {
+ "description": "ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ "type": "number"
+ },
+ "widget_type": {
+ "enum": ["activity_events_list"],
+ "type": "string"
+ }
+ },
+ "required": ["tile_id", "widget_type"],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "config": {
+ "description": "New configuration for the top issues widget. Omit to leave unchanged.",
+ "properties": {
+ "assignee": {
+ "anyOf": [
+ {
+ "properties": {
+ "id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "number"
+ }
+ ]
+ },
+ "type": {
+ "enum": ["user", "role"],
+ "type": "string"
+ }
+ },
+ "required": ["id", "type"],
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Filter by assignee ({type: user|role, id}). Omit for any assignee."
+ },
+ "dateRange": {
+ "anyOf": [
+ {
+ "properties": {
+ "date_from": {
+ "anyOf": [
+ {
+ "enum": [
+ "-1M",
+ "-30M",
+ "-1h",
+ "-3h",
+ "-24h",
+ "-7d",
+ "-14d",
+ "-30d",
+ "-90d"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "filterTestAccounts": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "limit": {
+ "default": 10,
+ "description": "Maximum number of issues to return.",
+ "maximum": 25,
+ "minimum": 1,
+ "type": "number"
+ },
+ "orderBy": {
+ "default": "occurrences",
+ "description": "Issue ranking column.",
+ "enum": ["last_seen", "first_seen", "occurrences", "users", "sessions"],
+ "type": "string"
+ },
+ "orderDirection": {
+ "default": "DESC",
+ "description": "Sort direction for orderBy.",
+ "enum": ["ASC", "DESC"],
+ "type": "string"
+ },
+ "status": {
+ "default": "active",
+ "description": "Issue status filter.",
+ "enum": [
+ "archived",
+ "active",
+ "resolved",
+ "pending_release",
+ "suppressed",
+ "all"
+ ],
+ "type": "string"
+ },
+ "widgetFilters": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "properties": {
+ "filterId": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "operator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex",
+ "gt",
+ "gte",
+ "lt",
+ "lte",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after",
+ "between",
+ "not_between",
+ "min",
+ "max",
+ "in",
+ "not_in",
+ "is_cleaned_path_exact",
+ "flag_evaluates_to",
+ "semver_eq",
+ "semver_neq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_tilde",
+ "semver_caret",
+ "semver_wildcard",
+ "icontains_multi",
+ "not_icontains_multi"
+ ],
+ "type": "string"
+ },
+ "optionId": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "propertyName": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["filterId", "propertyName", "optionId", "operator"],
+ "type": "object"
+ },
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "description": {
+ "description": "New markdown description for the widget. Omit to leave unchanged.",
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "New display name for the widget. Empty string or null clears it; omit to leave unchanged."
+ },
+ "tile_id": {
+ "description": "ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ "type": "number"
+ },
+ "widget_type": {
+ "enum": ["error_tracking_list"],
+ "type": "string"
+ }
+ },
+ "required": ["tile_id", "widget_type"],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "config": {
+ "description": "New configuration for the recent recordings widget. Omit to leave unchanged.",
+ "properties": {
+ "dateRange": {
+ "anyOf": [
+ {
+ "properties": {
+ "date_from": {
+ "anyOf": [
+ {
+ "enum": [
+ "-1M",
+ "-30M",
+ "-1h",
+ "-3h",
+ "-24h",
+ "-7d",
+ "-14d",
+ "-30d",
+ "-90d"
+ ],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "filterTestAccounts": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "limit": {
+ "default": 10,
+ "description": "Maximum number of recordings to return.",
+ "maximum": 25,
+ "minimum": 1,
+ "type": "number"
+ },
+ "orderBy": {
+ "default": "start_time",
+ "description": "Recording ranking column.",
+ "enum": [
+ "start_time",
+ "activity_score",
+ "recording_duration",
+ "duration",
+ "click_count",
+ "console_error_count"
+ ],
+ "type": "string"
+ },
+ "orderDirection": {
+ "default": "DESC",
+ "description": "Sort direction for orderBy.",
+ "enum": ["ASC", "DESC"],
+ "type": "string"
+ },
+ "savedFilterId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "short_id of a saved session replay filter to use as the recordings source. When set, the saved filter owns the date range and property filters; only orderBy, orderDirection, and limit still apply."
+ },
+ "widgetFilters": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "properties": {
+ "filterId": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "operator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "regex",
+ "not_regex",
+ "gt",
+ "gte",
+ "lt",
+ "lte",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after",
+ "between",
+ "not_between",
+ "min",
+ "max",
+ "in",
+ "not_in",
+ "is_cleaned_path_exact",
+ "flag_evaluates_to",
+ "semver_eq",
+ "semver_neq",
+ "semver_gt",
+ "semver_gte",
+ "semver_lt",
+ "semver_lte",
+ "semver_tilde",
+ "semver_caret",
+ "semver_wildcard",
+ "icontains_multi",
+ "not_icontains_multi"
+ ],
+ "type": "string"
+ },
+ "optionId": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "propertyName": {
+ "minLength": 1,
+ "type": "string"
+ },
+ "value": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": ["filterId", "propertyName", "optionId", "operator"],
+ "type": "object"
+ },
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "description": {
+ "description": "New markdown description for the widget. Omit to leave unchanged.",
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "New display name for the widget. Empty string or null clears it; omit to leave unchanged."
+ },
+ "tile_id": {
+ "description": "ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ "type": "number"
+ },
+ "widget_type": {
+ "enum": ["session_replay_list"],
+ "type": "string"
+ }
+ },
+ "required": ["tile_id", "widget_type"],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "config": {
+ "description": "New configuration for the experiments list widget. Omit to leave unchanged.",
+ "properties": {
+ "createdBy": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Filter by creator (user id). Omit for any creator."
+ },
+ "limit": {
+ "default": 10,
+ "description": "Maximum number of experiments to return.",
+ "maximum": 25,
+ "minimum": 1,
+ "type": "number"
+ },
+ "orderBy": {
+ "default": "created_at",
+ "description": "Experiment list sort column.",
+ "enum": ["created_at", "name", "start_date"],
+ "type": "string"
+ },
+ "orderDirection": {
+ "default": "DESC",
+ "description": "Sort direction for orderBy.",
+ "enum": ["ASC", "DESC"],
+ "type": "string"
+ },
+ "status": {
+ "default": "all",
+ "description": "Experiment status filter.",
+ "enum": ["draft", "running", "paused", "stopped", "all"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
+ "description": {
+ "description": "New markdown description for the widget. Omit to leave unchanged.",
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "New display name for the widget. Empty string or null clears it; omit to leave unchanged."
+ },
+ "tile_id": {
+ "description": "ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ "type": "number"
+ },
+ "widget_type": {
+ "enum": ["experiments_list"],
+ "type": "string"
+ }
+ },
+ "required": ["tile_id", "widget_type"],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "config": {
+ "description": "New configuration for the experiment results widget. Omit to leave unchanged.",
+ "properties": {
+ "experimentId": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Experiment to show results for. Null until the user picks one in the widget settings."
+ }
+ },
+ "type": "object"
+ },
+ "description": {
+ "description": "New markdown description for the widget. Omit to leave unchanged.",
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "New display name for the widget. Empty string or null clears it; omit to leave unchanged."
+ },
+ "tile_id": {
+ "description": "ID of the widget tile to update. Use dashboard-get to look up widget tile IDs.",
+ "type": "number"
+ },
+ "widget_type": {
+ "enum": ["experiment_results"],
+ "type": "string"
+ }
+ },
+ "required": ["tile_id", "widget_type"],
+ "type": "object"
+ }
+ ]
+ },
+ "maxItems": 10,
+ "minItems": 1,
+ "type": "array"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}