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(annotations): add hidden_in_user_interface flag (#65665)

Paul D'Ambra819f086eeecc
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index cce2f069711d..328d0155fe37 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -4160,12 +4160,17 @@ const api = {
): Promise<RawAnnotationType> {
return await new ApiRequest().annotation(annotationId).update({ data })
},
- async list(params?: { limit?: number; offset?: number }): Promise<PaginatedResponse<RawAnnotationType>> {
+ async list(params?: {
+ limit?: number
+ offset?: number
+ hidden_in_user_interface?: boolean
+ }): Promise<PaginatedResponse<RawAnnotationType>> {
return await new ApiRequest()
.annotations()
.withQueryString({
limit: params?.limit,
offset: params?.offset,
+ hidden_in_user_interface: params?.hidden_in_user_interface,
})
.get()
},
diff --git a/frontend/src/models/annotationsModel.ts b/frontend/src/models/annotationsModel.ts
index 2facb8e7c0b6..b97ba94326e4 100644
--- a/frontend/src/models/annotationsModel.ts
+++ b/frontend/src/models/annotationsModel.ts
@@ -44,7 +44,7 @@ export const annotationsModel = kea<annotationsModelType>([
rawAnnotations: {
__default: [],
loadAnnotations: async () => {
- const response = await api.annotations.list()
+ const response = await api.annotations.list({ hidden_in_user_interface: false })
actions.setNext(response.next || null)
return response.results
},
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 4d3f3af97f3d..03d95d74b153 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -2864,6 +2864,8 @@ export interface RawAnnotationType {
creation_type?: 'USR' | 'GIT'
/** Optional emoji shown in place of the default badge when surfacing the annotation. */
emoji?: string | null
+ /** When true, the annotation is hidden from the UI but still readable over the API and MCP. */
+ hidden_in_user_interface?: boolean | null
}
export interface AnnotationType extends Omit<RawAnnotationType, 'created_at' | 'date_marker'> {
diff --git a/products/annotations/backend/api/annotation.py b/products/annotations/backend/api/annotation.py
index 42c242eaffdc..fcc61c79690f 100644
--- a/products/annotations/backend/api/annotation.py
+++ b/products/annotations/backend/api/annotation.py
@@ -39,6 +39,7 @@ class AnnotationSerializer(serializers.ModelSerializer):
"deleted",
"scope",
"emoji",
+ "hidden_in_user_interface",
]
read_only_fields = [
"id",
@@ -81,6 +82,15 @@ class AnnotationSerializer(serializers.ModelSerializer):
"allow_null": True,
"allow_blank": True,
},
+ "hidden_in_user_interface": {
+ "help_text": (
+ "When true, the annotation is hidden from the PostHog UI (charts and the annotations list) "
+ "but still readable over the API and MCP. Use for high-frequency markers like deployments "
+ "that would otherwise crowd the UI. Null (the default) means the annotation is shown."
+ ),
+ "required": False,
+ "allow_null": True,
+ },
}
def validate_emoji(self, value: str | None) -> str | None:
@@ -191,6 +201,13 @@ class AnnotationsViewSet(TeamAndOrgViewSetMixin, ForbidDestroyModel, viewsets.Mo
is_emoji_bool = is_emoji.lower() in ("true", "1", "yes")
queryset = queryset.filter(is_emoji=is_emoji_bool)
+ hidden_in_user_interface = self.request.query_params.get("hidden_in_user_interface")
+ if hidden_in_user_interface is not None:
+ if hidden_in_user_interface.lower() in ("true", "1", "yes"):
+ queryset = queryset.filter(hidden_in_user_interface=True)
+ else:
+ queryset = queryset.filter(Q(hidden_in_user_interface=False) | Q(hidden_in_user_interface__isnull=True))
+
return queryset
def _filter_queryset_by_parents_lookups(self, queryset):
diff --git a/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr b/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr
index 8ffdca5aee12..5bd1ea2ab695 100644
--- a/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr
+++ b/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr
@@ -495,6 +495,7 @@
"posthog_annotation"."creation_type",
"posthog_annotation"."date_marker",
"posthog_annotation"."deleted",
+ "posthog_annotation"."hidden_in_user_interface",
"posthog_annotation"."apply_all",
"posthog_dashboarditem"."id",
"posthog_dashboarditem"."name",
@@ -1214,6 +1215,7 @@
"posthog_annotation"."creation_type",
"posthog_annotation"."date_marker",
"posthog_annotation"."deleted",
+ "posthog_annotation"."hidden_in_user_interface",
"posthog_annotation"."apply_all",
"posthog_dashboarditem"."id",
"posthog_dashboarditem"."name",
diff --git a/products/annotations/backend/api/test/test_annotation.py b/products/annotations/backend/api/test/test_annotation.py
index 3c95a548ba78..1362dad4ef39 100644
--- a/products/annotations/backend/api/test/test_annotation.py
+++ b/products/annotations/backend/api/test/test_annotation.py
@@ -263,6 +263,64 @@ class TestAnnotation(APIBaseTest, QueryMatchingTest):
test_annotation.refresh_from_db()
assert test_annotation.emoji is None
+ def test_creating_annotation_defaults_hidden_in_user_interface_to_null(self) -> None:
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/annotations/",
+ {"content": "Release shipped", "scope": "project", "date_marker": "2020-01-01T00:00:00.000000Z"},
+ )
+ assert response.status_code == status.HTTP_201_CREATED
+ assert response.json()["hidden_in_user_interface"] is None
+ instance = Annotation.objects.get(pk=response.json()["id"])
+ assert instance.hidden_in_user_interface is None
+
+ def test_creating_and_clearing_hidden_in_user_interface(self) -> None:
+ create_response = self.client.post(
+ f"/api/projects/{self.team.id}/annotations/",
+ {
+ "content": "Deployment",
+ "scope": "project",
+ "date_marker": "2020-01-01T00:00:00.000000Z",
+ "hidden_in_user_interface": True,
+ },
+ )
+ assert create_response.status_code == status.HTTP_201_CREATED
+ assert create_response.json()["hidden_in_user_interface"] is True
+
+ annotation_id = create_response.json()["id"]
+ clear_response = self.client.patch(
+ f"/api/projects/{self.team.id}/annotations/{annotation_id}/",
+ {"hidden_in_user_interface": None},
+ )
+ assert clear_response.status_code == status.HTTP_200_OK
+ assert clear_response.json()["hidden_in_user_interface"] is None
+
+ @parameterized.expand(
+ [
+ (None, {"hidden", "visible", "unset"}),
+ ("false", {"visible", "unset"}),
+ ("0", {"visible", "unset"}),
+ ("banana", {"visible", "unset"}),
+ ("true", {"hidden"}),
+ ("1", {"hidden"}),
+ ]
+ )
+ def test_filter_annotations_by_hidden_in_user_interface(
+ self, query_value: Optional[str], expected_contents: set[str]
+ ) -> None:
+ for content, hidden in (("hidden", True), ("visible", False), ("unset", None)):
+ Annotation.objects.create(
+ organization=self.organization,
+ team=self.team,
+ content=content,
+ scope=Annotation.Scope.PROJECT,
+ hidden_in_user_interface=hidden,
+ )
+
+ query = f"?hidden_in_user_interface={query_value}" if query_value is not None else ""
+ response = self.client.get(f"/api/projects/{self.team.id}/annotations/{query}")
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ assert {result["content"] for result in response.json()["results"]} == expected_contents
+
def test_deleting_annotation(self) -> None:
new_user = User.objects.create_and_join(self.organization, "[email protected]", None)
diff --git a/products/annotations/backend/migrations/0003_annotation_hidden_in_user_interface.py b/products/annotations/backend/migrations/0003_annotation_hidden_in_user_interface.py
new file mode 100644
index 000000000000..993ac2c45ce9
--- /dev/null
+++ b/products/annotations/backend/migrations/0003_annotation_hidden_in_user_interface.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.14 on 2026-06-23 20:34
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("annotations", "0002_annotation_emoji"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="annotation",
+ name="hidden_in_user_interface",
+ field=models.BooleanField(blank=True, null=True),
+ ),
+ ]
diff --git a/products/annotations/backend/migrations/max_migration.txt b/products/annotations/backend/migrations/max_migration.txt
index 425bf6a87f86..a76d998769c7 100644
--- a/products/annotations/backend/migrations/max_migration.txt
+++ b/products/annotations/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0002_annotation_emoji
+0003_annotation_hidden_in_user_interface
diff --git a/products/annotations/backend/models/annotation.py b/products/annotations/backend/models/annotation.py
index fd4a8364d9c7..3bf838b5bac5 100644
--- a/products/annotations/backend/models/annotation.py
+++ b/products/annotations/backend/models/annotation.py
@@ -35,6 +35,7 @@ class Annotation(ModelActivityMixin, models.Model):
creation_type = models.CharField(max_length=3, choices=CreationType, default=CreationType.USER)
date_marker = models.DateTimeField(null=True, blank=True)
deleted = models.BooleanField(default=False)
+ hidden_in_user_interface = models.BooleanField(null=True, blank=True)
# DEPRECATED: replaced by scope
apply_all = models.BooleanField(null=True)
diff --git a/products/annotations/frontend/generated/api.schemas.ts b/products/annotations/frontend/generated/api.schemas.ts
index 7f98d0947401..abc059b78659 100644
--- a/products/annotations/frontend/generated/api.schemas.ts
+++ b/products/annotations/frontend/generated/api.schemas.ts
@@ -140,6 +140,11 @@ export interface AnnotationApi {
* @nullable
*/
emoji?: string | null
+ /**
+ * When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.
+ * @nullable
+ */
+ hidden_in_user_interface?: boolean | null
}
export interface PaginatedAnnotationListApi {
@@ -201,6 +206,11 @@ export interface PatchedAnnotationApi {
* @nullable
*/
emoji?: string | null
+ /**
+ * When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.
+ * @nullable
+ */
+ hidden_in_user_interface?: boolean | null
}
export type AnnotationsListParams = {
diff --git a/products/annotations/frontend/generated/api.zod.ts b/products/annotations/frontend/generated/api.zod.ts
index 35fdec412596..32755b9f4303 100644
--- a/products/annotations/frontend/generated/api.zod.ts
+++ b/products/annotations/frontend/generated/api.zod.ts
@@ -53,6 +53,12 @@ export const AnnotationsCreateBody = /* @__PURE__ */ zod.object({
.max(annotationsCreateBodyEmojiMax)
.nullish()
.describe('Optional emoji shown in place of the default badge when this annotation is surfaced on a chart.'),
+ hidden_in_user_interface: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.'
+ ),
})
/**
@@ -99,6 +105,12 @@ export const AnnotationsUpdateBody = /* @__PURE__ */ zod.object({
.max(annotationsUpdateBodyEmojiMax)
.nullish()
.describe('Optional emoji shown in place of the default badge when this annotation is surfaced on a chart.'),
+ hidden_in_user_interface: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.'
+ ),
})
/**
@@ -145,4 +157,10 @@ export const AnnotationsPartialUpdateBody = /* @__PURE__ */ zod.object({
.max(annotationsPartialUpdateBodyEmojiMax)
.nullish()
.describe('Optional emoji shown in place of the default badge when this annotation is surfaced on a chart.'),
+ hidden_in_user_interface: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.'
+ ),
})
diff --git a/products/annotations/mcp/tools.yaml b/products/annotations/mcp/tools.yaml
index 06806c18d657..f55018a39c4b 100644
--- a/products/annotations/mcp/tools.yaml
+++ b/products/annotations/mcp/tools.yaml
@@ -29,6 +29,7 @@ tools:
- date_marker
- scope
- emoji
+ - hidden_in_user_interface
annotation-delete:
operation: annotations_destroy
enabled: true
@@ -92,6 +93,7 @@ tools:
- date_marker
- scope
- emoji
+ - hidden_in_user_interface
annotations-update:
operation: annotations_update
enabled: false
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d583e7be2a24..53fe3f668702 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -9218,6 +9218,11 @@ export namespace Schemas {
* @nullable
*/
emoji?: string | null;
+ /**
+ * When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.
+ * @nullable
+ */
+ hidden_in_user_interface?: boolean | null;
}
export interface AppMetricSeries {
@@ -34749,6 +34754,11 @@ export namespace Schemas {
* @nullable
*/
emoji?: string | null;
+ /**
+ * When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.
+ * @nullable
+ */
+ hidden_in_user_interface?: boolean | null;
}
export interface PatchedApprovalPolicy {
diff --git a/services/mcp/src/generated/annotations/api.ts b/services/mcp/src/generated/annotations/api.ts
index dfe615476fb5..aa5c984fc3f8 100644
--- a/services/mcp/src/generated/annotations/api.ts
+++ b/services/mcp/src/generated/annotations/api.ts
@@ -77,6 +77,12 @@ export const AnnotationsCreateBody = /* @__PURE__ */ zod.object({
.max(annotationsCreateBodyEmojiMax)
.nullish()
.describe('Optional emoji shown in place of the default badge when this annotation is surfaced on a chart.'),
+ hidden_in_user_interface: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.'
+ ),
})
/**
@@ -144,6 +150,12 @@ export const AnnotationsPartialUpdateBody = /* @__PURE__ */ zod.object({
.max(annotationsPartialUpdateBodyEmojiMax)
.nullish()
.describe('Optional emoji shown in place of the default badge when this annotation is surfaced on a chart.'),
+ hidden_in_user_interface: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown.'
+ ),
})
/**
diff --git a/services/mcp/src/tools/generated/annotations.ts b/services/mcp/src/tools/generated/annotations.ts
index c803902767d6..24936a918b1c 100644
--- a/services/mcp/src/tools/generated/annotations.ts
+++ b/services/mcp/src/tools/generated/annotations.ts
@@ -39,6 +39,9 @@ const annotationCreate = (): ToolBase<typeof AnnotationCreateSchema, Schemas.Ann
if (params.emoji !== undefined) {
body['emoji'] = params.emoji
}
+ if (params.hidden_in_user_interface !== undefined) {
+ body['hidden_in_user_interface'] = params.hidden_in_user_interface
+ }
const result = await context.api.request<Schemas.Annotation>({
method: 'POST',
path: `/api/projects/${encodeURIComponent(String(projectId))}/annotations/`,
@@ -127,6 +130,9 @@ const annotationsPartialUpdate = (): ToolBase<typeof AnnotationsPartialUpdateSch
if (params.emoji !== undefined) {
body['emoji'] = params.emoji
}
+ if (params.hidden_in_user_interface !== undefined) {
+ body['hidden_in_user_interface'] = params.hidden_in_user_interface
+ }
const result = await context.api.request<Schemas.Annotation>({
method: 'PATCH',
path: `/api/projects/${encodeURIComponent(String(projectId))}/annotations/${encodeURIComponent(String(params.id))}/`,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json
index 7777e9acb20c..ceef95f07dbc 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json
@@ -38,6 +38,17 @@
],
"description": "Optional emoji shown in place of the default badge when this annotation is surfaced on a chart."
},
+ "hidden_in_user_interface": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown."
+ },
"scope": {
"description": "Annotation visibility scope: `project`, `organization`, `dashboard`, or `dashboard_item`. `recording` is deprecated and rejected.\n\n* `dashboard_item` - insight\n* `dashboard` - dashboard\n* `project` - project\n* `organization` - organization\n* `recording` - recording",
"enum": ["dashboard_item", "dashboard", "project", "organization", "recording"],
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json
index 58c8feb6a948..5babd181fcc5 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json
@@ -38,6 +38,17 @@
],
"description": "Optional emoji shown in place of the default badge when this annotation is surfaced on a chart."
},
+ "hidden_in_user_interface": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "When true, the annotation is hidden from the PostHog UI (charts and the annotations list) but still readable over the API and MCP. Use for high-frequency markers like deployments that would otherwise crowd the UI. Null (the default) means the annotation is shown."
+ },
"id": {
"description": "A unique integer value identifying this annotation.",
"type": "number"