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(workflows): add base MCP tools for workflows product (#60388)

Harley Alexander6970121e6400
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 9b575cc8baf8..e1b61c0ade86 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -514,6 +514,7 @@ SPECTACULAR_SETTINGS = {
"ExistenceOperatorEnum": ["is_set", "is_not_set"],
"TaskExecutionModeEnum": ["interactive", "background"],
"HogFunctionTemplatingEnum": ["hog", "liquid"],
+ "HogFlowEdgeTypeEnum": ["continue", "branch"],
"SourceMatchEnum": ["none", "auto", "mapped"],
"NotificationDestinationTypeEnum": ["slack", "webhook"],
"TaskRunArtifactTypeEnum": [
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index a0904f599b77..0512ff863237 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -75,19 +75,70 @@ class HogFlowConfigFunctionInputsSerializer(serializers.Serializer):
return super().to_internal_value(data)
+class HogFlowEdgeSerializer(serializers.Serializer):
+ to = serializers.CharField(help_text="Target action id.")
+ type = serializers.ChoiceField(
+ choices=["continue", "branch"],
+ help_text=(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). "
+ "branch: requires 'index' matching config.conditions[index]."
+ ),
+ )
+ index = serializers.IntegerField(
+ required=False,
+ help_text="Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition.",
+ )
+
+ def get_fields(self):
+ # 'from' is a Python keyword so it can't be a class attribute. Inject it here
+ # so DRF / drf-spectacular still see a typed field on the wire.
+ fields = super().get_fields()
+ fields["from"] = serializers.CharField(help_text="Source action id.")
+ return fields
+
+
class HogFlowActionSerializer(serializers.Serializer):
- id = serializers.CharField()
- name = serializers.CharField(max_length=400)
- description = serializers.CharField(allow_blank=True, default="")
+ id = serializers.CharField(help_text="Unique node ID within the workflow.")
+ name = serializers.CharField(max_length=400, help_text="Display name.")
+ description = serializers.CharField(allow_blank=True, default="", help_text="Optional description.")
on_error = serializers.ChoiceField(
- choices=["continue", "abort", "complete", "branch"], required=False, allow_null=True
+ choices=["continue", "abort", "complete", "branch"],
+ required=False,
+ allow_null=True,
+ help_text="On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).",
+ )
+ created_at = serializers.IntegerField(required=False, help_text="Created at (epoch ms). Frontend-managed.")
+ updated_at = serializers.IntegerField(required=False, help_text="Updated at (epoch ms). Frontend-managed.")
+ filters = HogFunctionFiltersSerializer(
+ required=False, default=None, allow_null=True, help_text="Property filters gating this action."
+ )
+ type = serializers.CharField(
+ max_length=100,
+ help_text=(
+ "trigger | function | function_email | function_sms | function_push | delay | "
+ "conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit."
+ ),
+ )
+ config = serializers.JSONField(
+ help_text=(
+ "Type-specific config keyed by action type. "
+ "trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. "
+ "filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], "
+ "actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, "
+ "type: event|person|group}. "
+ "function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable "
+ "hog templating ({person.x}, {event.x}); flat strings won't interpolate. "
+ "delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; "
+ "seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. "
+ "Max 30d. "
+ "conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. "
+ "wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). "
+ "exit: {reason}."
+ ),
+ )
+ output_variable = serializers.JSONField(
+ required=False, allow_null=True, help_text="Output variable definition for downstream actions."
)
- created_at = serializers.IntegerField(required=False)
- updated_at = serializers.IntegerField(required=False)
- filters = HogFunctionFiltersSerializer(required=False, default=None, allow_null=True)
- type = serializers.CharField(max_length=100)
- config = serializers.JSONField()
- output_variable = serializers.JSONField(required=False, allow_null=True)
def to_internal_value(self, data):
# Weirdly nested serializers don't get this set...
@@ -190,7 +241,8 @@ class HogFlowActionSerializer(serializers.Serializer):
{
"config": (
"delay_duration must be a string matching ^\\d*\\.?\\d+[dhm]$ "
- "(e.g. '30m', '2h', '1d'). Seconds and ISO-8601 formats are not supported."
+ "(e.g. '30m', '2h', '1d'). ISO-8601 formats are not supported. "
+ "For seconds, use a fraction of a minute."
)
}
)
@@ -201,6 +253,7 @@ class HogFlowActionSerializer(serializers.Serializer):
class HogFlowVariableSerializer(serializers.ListSerializer):
child = serializers.DictField(
child=serializers.CharField(allow_blank=True),
+ help_text="Variable: {key, type: string|number|boolean, default}.",
)
def validate(self, attrs):
@@ -220,10 +273,18 @@ class HogFlowVariableSerializer(serializers.ListSerializer):
class HogFlowMaskingSerializer(serializers.Serializer):
- ttl = serializers.IntegerField(required=False, min_value=60, max_value=60 * 60 * 24 * 365 * 3, allow_null=True)
- threshold = serializers.IntegerField(required=False, allow_null=True)
- hash = serializers.CharField(required=True)
- bytecode = serializers.JSONField(required=False, allow_null=True)
+ ttl = serializers.IntegerField(
+ required=False,
+ min_value=60,
+ max_value=60 * 60 * 24 * 365 * 3,
+ allow_null=True,
+ help_text="Hash TTL in seconds (60 to ~94M / 3y).",
+ )
+ threshold = serializers.IntegerField(
+ required=False, allow_null=True, help_text="Min matching events before triggering (k-anonymity)."
+ )
+ hash = serializers.CharField(required=True, help_text="HogQL template, e.g. '{person.properties.email}'.")
+ bytecode = serializers.JSONField(required=False, allow_null=True, help_text="Auto-compiled from hash. Do not set.")
def validate(self, attrs):
attrs["bytecode"] = generate_template_bytecode(attrs["hash"], input_collector=set())
@@ -316,9 +377,58 @@ class HogFlowMinimalSerializer(serializers.ModelSerializer):
class HogFlowSerializer(HogFlowMinimalSerializer):
- actions = serializers.ListField(child=HogFlowActionSerializer(), required=True)
- trigger_masking = HogFlowMaskingSerializer(required=False, allow_null=True)
- variables = HogFlowVariableSerializer(required=False)
+ name = serializers.CharField(
+ max_length=400, required=False, allow_null=True, allow_blank=True, help_text="Workflow name."
+ )
+ description = serializers.CharField(required=False, allow_blank=True, default="", help_text="Optional description.")
+ status = serializers.ChoiceField(
+ choices=HogFlow.State.choices,
+ required=False,
+ help_text="draft (no execution), active (live), archived (disabled).",
+ )
+ trigger_masking = HogFlowMaskingSerializer(
+ required=False,
+ allow_null=True,
+ help_text=(
+ "Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. "
+ "Server compiles bytecode from hash. Omit to disable."
+ ),
+ )
+ conversion = serializers.JSONField(
+ required=False,
+ allow_null=True,
+ help_text=(
+ "Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, "
+ "type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / "
+ "exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
+ ),
+ )
+ exit_condition = serializers.ChoiceField(
+ choices=HogFlow.ExitCondition.choices,
+ required=False,
+ help_text=(
+ "exit_only_at_end: only at exit node (default). "
+ "exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). "
+ "exit_on_trigger_not_matched: also when trigger filter stops matching. "
+ "exit_on_trigger_not_matched_or_conversion: both (needs 'conversion')."
+ ),
+ )
+ edges = serializers.ListField(
+ child=HogFlowEdgeSerializer(),
+ required=False,
+ help_text=(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through "
+ "(sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches "
+ "config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action "
+ "needs a reachable next action ('No next action found' otherwise)."
+ ),
+ )
+ actions = serializers.ListField(
+ child=HogFlowActionSerializer(),
+ required=True,
+ help_text="Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too.",
+ )
+ variables = HogFlowVariableSerializer(required=False, help_text="Workflow vars (key, type, default). Total <5KB.")
def to_internal_value(self, data):
status = data.get("status")
@@ -354,6 +464,8 @@ class HogFlowSerializer(HogFlowMinimalSerializer):
"version",
"created_at",
"created_by",
+ "updated_at",
+ "trigger", # Derived from the trigger action in the actions array
"abort_action",
"billable_action_types", # Computed field, not user-editable
]
@@ -417,10 +529,20 @@ class HogFlowSerializer(HogFlowMinimalSerializer):
class HogFlowInvocationSerializer(serializers.Serializer):
- configuration = HogFlowSerializer(write_only=True, required=False)
- globals = serializers.DictField(write_only=True, required=False)
- mock_async_functions = serializers.BooleanField(default=True, write_only=True)
- current_action_id = serializers.CharField(write_only=True, required=False)
+ configuration = HogFlowSerializer(
+ write_only=True, required=False, help_text="Optional override; omit to use saved definition."
+ )
+ globals = serializers.DictField(
+ write_only=True, required=False, help_text="Test trigger payload, typically {event, person, groups}."
+ )
+ mock_async_functions = serializers.BooleanField(
+ default=True,
+ write_only=True,
+ help_text="True (default) mocks HTTP/email/SMS. False fires real side effects.",
+ )
+ current_action_id = serializers.CharField(
+ write_only=True, required=False, help_text="Start from this action ID instead of the trigger."
+ )
class CommaSeparatedListFilter(BaseInFilter, CharFilter):
@@ -430,13 +552,14 @@ class CommaSeparatedListFilter(BaseInFilter, CharFilter):
class HogFlowFilterSet(FilterSet):
class Meta:
model = HogFlow
- fields = ["id", "created_by", "created_at", "updated_at"]
+ fields = ["id", "created_by", "created_at", "updated_at", "status"]
@extend_schema(extensions={"x-product": "workflows"})
class HogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMixin, viewsets.ModelViewSet):
scope_object = "hog_flow"
scope_object_read_actions = ["list", "retrieve", "logs", "metrics", "metrics_totals"]
+ scope_object_write_actions = ["create", "update", "partial_update", "destroy", "invocations"]
queryset = HogFlow.objects.all()
filter_backends = [DjangoFilterBackend]
filterset_class = HogFlowFilterSet
@@ -465,7 +588,17 @@ class HogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMixin, vie
# TODO(team-workflows): Somehow implement version lookups
return super().safely_get_object(queryset)
+ @staticmethod
+ def _is_mcp_request(request: Request) -> bool:
+ return request.headers.get("x-posthog-client") == "mcp"
+
def perform_create(self, serializer):
+ if self._is_mcp_request(self.request) and serializer.validated_data.get("status") == HogFlow.State.ACTIVE:
+ raise exceptions.ValidationError(
+ "You can't one-shot active workflows via MCP. "
+ "Create as draft, test with workflows-run, then enable with workflows-enable."
+ )
+
serializer.save()
log_activity_from_viewset(self, serializer.instance, name=serializer.instance.name, detail_type="standard")
@@ -491,6 +624,33 @@ class HogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMixin, vie
logger.warning("Failed to capture hog_flow_created event", error=str(e))
def perform_update(self, serializer):
+ # Guardrails for MCP callers (gated on x-posthog-client: mcp; the frontend and raw API
+ # are unaffected). We check the raw request payload, not serializer.validated_data —
+ # HogFlowSerializer.validate injects derived fields like 'trigger' and
+ # 'billable_action_types' which would otherwise make every status-only PATCH look like
+ # an edit.
+ if self._is_mcp_request(self.request):
+ keys = set(self.request.data.keys())
+ has_status = "status" in keys
+ has_non_status = bool(keys - {"status"})
+
+ # 1. Live workflows can't be edited. Status-only PATCHes (i.e. the lifecycle
+ # tools) pass through.
+ if serializer.instance.status == HogFlow.State.ACTIVE and has_non_status:
+ raise exceptions.ValidationError(
+ "You can't edit an enabled (active) workflow via MCP. "
+ "Disable it first with workflows-disable, then make your changes."
+ )
+
+ # 2. Status changes must go through the dedicated lifecycle tools, which send
+ # status-only PATCHes. Mixed payloads are rejected so MCP can't sneak a status
+ # transition through workflows-update.
+ if has_status and has_non_status:
+ raise exceptions.ValidationError(
+ "Status changes via MCP must use workflows-enable / workflows-disable / "
+ "workflows-archive — they can't be combined with other field updates."
+ )
+
# TODO(team-workflows): Atomically increment version, insert new object instead of default update behavior
instance_id = serializer.instance.id
@@ -530,6 +690,7 @@ class HogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMixin, vie
except Exception as e:
logger.warning("Failed to capture hog_flow_activated event", error=str(e))
+ @extend_schema(request=HogFlowInvocationSerializer, responses={200: _FallbackSerializer})
@action(detail=True, methods=["POST"])
def invocations(self, request: Request, *args, **kwargs):
try:
diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.py
index d9d12a76baed..0e3d3efc105e 100644
--- a/products/workflows/backend/api/test/test_hog_flow.py
+++ b/products/workflows/backend/api/test/test_hog_flow.py
@@ -1,7 +1,7 @@
from typing import Optional
from posthog.test.base import APIBaseTest
-from unittest.mock import patch
+from unittest.mock import MagicMock, patch
from parameterized import parameterized
from rest_framework import status
@@ -149,7 +149,8 @@ class TestHogFlowAPI(APIBaseTest):
"code": "invalid_input",
"detail": (
"delay_duration must be a string matching ^\\d*\\.?\\d+[dhm]$ "
- "(e.g. '30m', '2h', '1d'). Seconds and ISO-8601 formats are not supported."
+ "(e.g. '30m', '2h', '1d'). ISO-8601 formats are not supported. "
+ "For seconds, use a fraction of a minute."
),
"type": "validation_error",
}
@@ -552,6 +553,162 @@ class TestHogFlowAPI(APIBaseTest):
assert response.status_code == 200, response.json()
assert response.json()["status"] == "draft"
+ def _create_active_hog_flow(self) -> str:
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create.status_code == 201, create.json()
+ flow_id = create.json()["id"]
+ activate = self.client.patch(f"/api/projects/{self.team.id}/hog_flows/{flow_id}", {"status": "active"})
+ assert activate.status_code == 200, activate.json()
+ return flow_id
+
+ def test_mcp_cannot_modify_active_workflow(self):
+ flow_id = self._create_active_hog_flow()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
+ {"name": "Renamed via MCP"},
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+ assert response.status_code == 400, response.json()
+ assert "enabled (active) workflow via MCP" in response.json()["detail"]
+
+ @parameterized.expand([("disable_to_draft", "draft"), ("archive", "archived")])
+ def test_mcp_can_disable_active_workflow(self, _name, target_status):
+ flow_id = self._create_active_hog_flow()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
+ {"status": target_status},
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+ assert response.status_code == 200, response.json()
+ assert response.json()["status"] == target_status
+
+ def test_mcp_can_modify_draft_workflow(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create.status_code == 201, create.json()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{create.json()['id']}",
+ {"name": "Renamed via MCP"},
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+ assert response.status_code == 200, response.json()
+ assert response.json()["name"] == "Renamed via MCP"
+
+ def test_non_mcp_can_modify_active_workflow(self):
+ flow_id = self._create_active_hog_flow()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}",
+ {"name": "Renamed via UI"},
+ )
+ assert response.status_code == 200, response.json()
+ assert response.json()["name"] == "Renamed via UI"
+
+ def test_mcp_cannot_create_active_workflow(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ hog_flow["status"] = "active"
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow, HTTP_X_POSTHOG_CLIENT="mcp")
+ assert response.status_code == 400, response.json()
+ assert "one-shot active workflows via MCP" in response.json()["detail"]
+
+ def test_mcp_can_create_draft_workflow(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow, HTTP_X_POSTHOG_CLIENT="mcp")
+ assert response.status_code == 201, response.json()
+ assert response.json()["status"] == "draft"
+
+ def test_non_mcp_can_create_active_workflow(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ hog_flow["status"] = "active"
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert response.status_code == 201, response.json()
+ assert response.json()["status"] == "active"
+
+ def test_mcp_cannot_mix_status_with_other_field_updates(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create.status_code == 201, create.json()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{create.json()['id']}",
+ {"name": "Renamed", "status": "active"},
+ HTTP_X_POSTHOG_CLIENT="mcp",
+ )
+ assert response.status_code == 400, response.json()
+ assert "workflows-enable / workflows-disable / workflows-archive" in response.json()["detail"]
+
+ def test_non_mcp_can_mix_status_with_other_field_updates(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create.status_code == 201, create.json()
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/hog_flows/{create.json()['id']}",
+ {"name": "Renamed", "status": "active"},
+ )
+ assert response.status_code == 200, response.json()
+ assert response.json()["status"] == "active"
+ assert response.json()["name"] == "Renamed"
+
+ def test_edges_validation_accepts_list_of_edges(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ hog_flow["edges"] = [{"from": "trigger_node", "to": "action_1", "type": "continue"}]
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert response.status_code == 201, response.json()
+ assert response.json()["edges"] == [{"from": "trigger_node", "to": "action_1", "type": "continue"}]
+
+ def test_edges_validation_rejects_non_list(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ hog_flow["edges"] = "not-an-array"
+ response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert response.status_code == 400, response.json()
+ assert response.json()["attr"] == "edges"
+
+ def test_can_call_a_test_invocation(self):
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {"template_id": "template-webhook", "inputs": {"url": {"value": "https://example.com"}}}
+ )
+ create = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create.status_code == 201, create.json()
+ flow_id = create.json()["id"]
+
+ with patch("posthog.api.hog_flow.create_hog_flow_invocation_test") as mock_invoke:
+ mock_invoke.return_value = MagicMock(status_code=200, json=lambda: {"status": "success"})
+
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/hog_flows/{flow_id}/invocations/",
+ data={
+ "globals": {"event": {"event": "$pageview", "distinct_id": "test-distinct-id"}},
+ "mock_async_functions": True,
+ },
+ )
+
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ assert response.json() == {"status": "success"}
+
+ assert mock_invoke.call_count == 1
+ assert mock_invoke.call_args.kwargs["team_id"] == self.team.id
+ assert mock_invoke.call_args.kwargs["hog_flow_id"] == flow_id
+ payload = mock_invoke.call_args.kwargs["payload"]
+ assert payload["globals"] == {"event": {"event": "$pageview", "distinct_id": "test-distinct-id"}}
+ assert payload["mock_async_functions"] is True
+
def test_hog_flow_conditional_event_filter_rejected(self):
conditional_action = {
"id": "cond_1",
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index 95b124cf6e21..07b08b72447c 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -22,14 +22,20 @@ export const HogFlowTemplateScopeEnumApi = {
export interface HogFlowMaskingApi {
/**
+ * Hash TTL in seconds (60 to ~94M / 3y).
* @minimum 60
* @maximum 94608000
* @nullable
*/
ttl?: number | null
- /** @nullable */
+ /**
+ * Min matching events before triggering (k-anonymity).
+ * @nullable
+ */
threshold?: number | null
+ /** HogQL template, e.g. '{person.properties.email}'. */
hash: string
+ /** Auto-compiled from hash. Do not set. */
bytecode?: unknown
}
@@ -121,6 +127,9 @@ export interface HogFlowTemplateActionApi {
*/
export type HogFlowTemplateApiCreatedBy = { [key: string]: unknown } | null
+/**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type HogFlowTemplateApiVariablesItem = { [key: string]: string }
/**
@@ -171,6 +180,9 @@ export interface PaginatedHogFlowTemplateListApi {
*/
export type PatchedHogFlowTemplateApiCreatedBy = { [key: string]: unknown } | null
+/**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type PatchedHogFlowTemplateApiVariablesItem = { [key: string]: string }
/**
@@ -306,75 +318,177 @@ export interface PaginatedHogFlowMinimalListApi {
results: HogFlowMinimalApi[]
}
+/**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type HogFlowApiVariablesItem = { [key: string]: string }
+/**
+ * * `continue` - continue
+ * `branch` - branch
+ */
+export type HogFlowEdgeTypeEnumApi = (typeof HogFlowEdgeTypeEnumApi)[keyof typeof HogFlowEdgeTypeEnumApi]
+
+export const HogFlowEdgeTypeEnumApi = {
+ Continue: 'continue',
+ Branch: 'branch',
+} as const
+
+export interface HogFlowEdgeApi {
+ /** Target action id. */
+ to: string
+ /** continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].
+
+ * `continue` - continue
+ * `branch` - branch */
+ type: HogFlowEdgeTypeEnumApi
+ /** Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition. */
+ index?: number
+ /** Source action id. */
+ from: string
+}
+
export interface HogFlowActionApi {
+ /** Unique node ID within the workflow. */
id: string
- /** @maxLength 400 */
+ /**
+ * Display name.
+ * @maxLength 400
+ */
name: string
+ /** Optional description. */
description?: string
+ /** On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).
+
+ * `continue` - continue
+ * `abort` - abort
+ * `complete` - complete
+ * `branch` - branch */
on_error?: OnErrorEnumApi | null
+ /** Created at (epoch ms). Frontend-managed. */
created_at?: number
+ /** Updated at (epoch ms). Frontend-managed. */
updated_at?: number
+ /** Property filters gating this action. */
filters?: HogFunctionFiltersApi | null
- /** @maxLength 100 */
+ /**
+ * trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.
+ * @maxLength 100
+ */
type: string
+ /** Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}. */
config: unknown
+ /** Output variable definition for downstream actions. */
output_variable?: unknown
}
export interface HogFlowApi {
readonly id: string
/**
+ * Workflow name.
* @maxLength 400
* @nullable
*/
name?: string | null
+ /** Optional description. */
description?: string
readonly version: number
+ /** draft (no execution), active (live), archived (disabled).
+
+ * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived */
status?: HogFlowStatusEnumApi
readonly created_at: string
readonly created_by: UserBasicApi
readonly updated_at: string
- trigger?: unknown
+ readonly trigger: unknown
+ /** Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable. */
trigger_masking?: HogFlowMaskingApi | null
+ /** Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */
conversion?: unknown
+ /** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').
+
+ * `exit_on_conversion` - Conversion
+ * `exit_on_trigger_not_matched` - Trigger Not Matched
+ * `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion
+ * `exit_only_at_end` - Only At End */
exit_condition?: ExitConditionEnumApi
- edges?: unknown
+ /** Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise). */
+ edges?: HogFlowEdgeApi[]
+ /** Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too. */
actions: HogFlowActionApi[]
/** @nullable */
readonly abort_action: string | null
+ /** Workflow vars (key, type, default). Total <5KB. */
variables?: HogFlowApiVariablesItem[]
readonly billable_action_types: unknown
}
+/**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type PatchedHogFlowApiVariablesItem = { [key: string]: string }
export interface PatchedHogFlowApi {
readonly id?: string
/**
+ * Workflow name.
* @maxLength 400
* @nullable
*/
name?: string | null
+ /** Optional description. */
description?: string
readonly version?: number
+ /** draft (no execution), active (live), archived (disabled).
+
+ * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived */
status?: HogFlowStatusEnumApi
readonly created_at?: string
readonly created_by?: UserBasicApi
readonly updated_at?: string
- trigger?: unknown
+ readonly trigger?: unknown
+ /** Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable. */
trigger_masking?: HogFlowMaskingApi | null
+ /** Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */
conversion?: unknown
+ /** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').
+
+ * `exit_on_conversion` - Conversion
+ * `exit_on_trigger_not_matched` - Trigger Not Matched
+ * `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion
+ * `exit_only_at_end` - Only At End */
exit_condition?: ExitConditionEnumApi
- edges?: unknown
+ /** Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise). */
+ edges?: HogFlowEdgeApi[]
+ /** Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too. */
actions?: HogFlowActionApi[]
/** @nullable */
readonly abort_action?: string | null
+ /** Workflow vars (key, type, default). Total <5KB. */
variables?: PatchedHogFlowApiVariablesItem[]
readonly billable_action_types?: unknown
}
+/**
+ * Test trigger payload, typically {event, person, groups}.
+ */
+export type HogFlowInvocationApiGlobals = { [key: string]: unknown }
+
+export interface HogFlowInvocationApi {
+ /** Optional override; omit to use saved definition. */
+ configuration?: HogFlowApi
+ /** Test trigger payload, typically {event, person, groups}. */
+ globals?: HogFlowInvocationApiGlobals
+ /** True (default) mocks HTTP/email/SMS. False fires real side effects. */
+ mock_async_functions?: boolean
+ /** Start from this action ID instead of the trigger. */
+ current_action_id?: string
+}
+
export interface AppMetricSeriesApi {
name: string
values: number[]
@@ -505,9 +619,23 @@ export type HogFlowsListParams = {
* The initial index from which to return the results.
*/
offset?: number
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: HogFlowsListStatus
updated_at?: string
}
+export type HogFlowsListStatus = (typeof HogFlowsListStatus)[keyof typeof HogFlowsListStatus]
+
+export const HogFlowsListStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+} as const
+
export type HogFlowsLogsRetrieveParams = {
/**
* Only return entries after this ISO 8601 timestamp.
@@ -676,9 +804,23 @@ export type HogFlowsSchedulesListParams = {
* The initial index from which to return the results.
*/
offset?: number
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: HogFlowsSchedulesListStatus
updated_at?: string
}
+export type HogFlowsSchedulesListStatus = (typeof HogFlowsSchedulesListStatus)[keyof typeof HogFlowsSchedulesListStatus]
+
+export const HogFlowsSchedulesListStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+} as const
+
export type HogFlowsSchedulesCreateParams = {
created_at?: string
created_by?: number
@@ -691,5 +833,20 @@ export type HogFlowsSchedulesCreateParams = {
* The initial index from which to return the results.
*/
offset?: number
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: HogFlowsSchedulesCreateStatus
updated_at?: string
}
+
+export type HogFlowsSchedulesCreateStatus =
+ (typeof HogFlowsSchedulesCreateStatus)[keyof typeof HogFlowsSchedulesCreateStatus]
+
+export const HogFlowsSchedulesCreateStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+} as const
diff --git a/products/workflows/frontend/generated/api.ts b/products/workflows/frontend/generated/api.ts
index 41ea54ef83fc..13f9fbc195f1 100644
--- a/products/workflows/frontend/generated/api.ts
+++ b/products/workflows/frontend/generated/api.ts
@@ -14,6 +14,7 @@ import type {
BlastRadiusApi,
BlastRadiusRequestApi,
HogFlowApi,
+ HogFlowInvocationApi,
HogFlowTemplateApi,
HogFlowTemplatesListParams,
HogFlowTemplatesLogsRetrieveParams,
@@ -349,14 +350,14 @@ export const getHogFlowsInvocationsCreateUrl = (projectId: string, id: string) =
export const hogFlowsInvocationsCreate = async (
projectId: string,
id: string,
- hogFlowApi: NonReadonly<HogFlowApi>,
+ hogFlowInvocationApi?: HogFlowInvocationApi,
options?: RequestInit
-): Promise<HogFlowApi> => {
- return apiMutator<HogFlowApi>(getHogFlowsInvocationsCreateUrl(projectId, id), {
+): Promise<void> => {
+ return apiMutator<void>(getHogFlowsInvocationsCreateUrl(projectId, id), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(hogFlowApi),
+ body: JSON.stringify(hogFlowInvocationApi),
})
}
diff --git a/products/workflows/frontend/generated/api.zod.ts b/products/workflows/frontend/generated/api.zod.ts
index f0488b8a1338..7e343d90d90c 100644
--- a/products/workflows/frontend/generated/api.zod.ts
+++ b/products/workflows/frontend/generated/api.zod.ts
@@ -41,10 +41,11 @@ export const HogFlowTemplatesCreateBody = /* @__PURE__ */ zod
.number()
.min(hogFlowTemplatesCreateBodyTriggerMaskingOneTtlMin)
.max(hogFlowTemplatesCreateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
@@ -110,7 +111,13 @@ export const HogFlowTemplatesCreateBody = /* @__PURE__ */ zod
)
),
abort_action: zod.string().max(hogFlowTemplatesCreateBodyAbortActionMax).nullish(),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ variables: zod
+ .array(
+ zod
+ .record(zod.string(), zod.string())
+ .describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional(),
})
.describe(
'Serializer for creating hog flow templates.\nValidates and sanitizes the workflow before creating it as a template.'
@@ -148,10 +155,11 @@ export const HogFlowTemplatesUpdateBody = /* @__PURE__ */ zod
.number()
.min(hogFlowTemplatesUpdateBodyTriggerMaskingOneTtlMin)
.max(hogFlowTemplatesUpdateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
@@ -217,7 +225,13 @@ export const HogFlowTemplatesUpdateBody = /* @__PURE__ */ zod
)
),
abort_action: zod.string().max(hogFlowTemplatesUpdateBodyAbortActionMax).nullish(),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ variables: zod
+ .array(
+ zod
+ .record(zod.string(), zod.string())
+ .describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional(),
})
.describe(
'Serializer for creating hog flow templates.\nValidates and sanitizes the workflow before creating it as a template.'
@@ -256,10 +270,11 @@ export const HogFlowTemplatesPartialUpdateBody = /* @__PURE__ */ zod
.number()
.min(hogFlowTemplatesPartialUpdateBodyTriggerMaskingOneTtlMin)
.max(hogFlowTemplatesPartialUpdateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
@@ -329,7 +344,13 @@ export const HogFlowTemplatesPartialUpdateBody = /* @__PURE__ */ zod
)
.optional(),
abort_action: zod.string().max(hogFlowTemplatesPartialUpdateBodyAbortActionMax).nullish(),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ variables: zod
+ .array(
+ zod
+ .record(zod.string(), zod.string())
+ .describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional(),
})
.describe(
'Serializer for creating hog flow templates.\nValidates and sanitizes the workflow before creating it as a template.'
@@ -337,6 +358,7 @@ export const HogFlowTemplatesPartialUpdateBody = /* @__PURE__ */ zod
export const hogFlowsCreateBodyNameMax = 400
+export const hogFlowsCreateBodyDescriptionDefault = ``
export const hogFlowsCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsCreateBodyTriggerMaskingOneTtlMax = 94608000
@@ -347,13 +369,15 @@ export const hogFlowsCreateBodyActionsItemFiltersOneSourceDefault = `events`
export const hogFlowsCreateBodyActionsItemTypeMax = 100
export const HogFlowsCreateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsCreateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsCreateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsCreateBodyDescriptionDefault).describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -361,15 +385,24 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsCreateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsCreateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -377,59 +410,111 @@ export const HogFlowsCreateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
),
- edges: zod.unknown().optional(),
- actions: zod.array(
- zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsCreateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsCreateBodyActionsItemDescriptionDefault),
- on_error: zod
- .union([
- zod
- .enum(['continue', 'abort', 'complete', 'branch'])
- .describe(
- '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
- ),
- zod.null(),
- ])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsCreateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsCreateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
.describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsCreateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- type: zod.string().max(hogFlowsCreateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
- })
- ),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsCreateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsCreateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
})
export const hogFlowsUpdateBodyNameMax = 400
+export const hogFlowsUpdateBodyDescriptionDefault = ``
export const hogFlowsUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsUpdateBodyTriggerMaskingOneTtlMax = 94608000
@@ -440,13 +525,15 @@ export const hogFlowsUpdateBodyActionsItemFiltersOneSourceDefault = `events`
export const hogFlowsUpdateBodyActionsItemTypeMax = 100
export const HogFlowsUpdateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsUpdateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsUpdateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsUpdateBodyDescriptionDefault).describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -454,15 +541,24 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsUpdateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsUpdateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -470,59 +566,111 @@ export const HogFlowsUpdateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
),
- edges: zod.unknown().optional(),
- actions: zod.array(
- zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsUpdateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsUpdateBodyActionsItemDescriptionDefault),
- on_error: zod
- .union([
- zod
- .enum(['continue', 'abort', 'complete', 'branch'])
- .describe(
- '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
- ),
- zod.null(),
- ])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsUpdateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsUpdateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
.describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsUpdateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- type: zod.string().max(hogFlowsUpdateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
- })
- ),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsUpdateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsUpdateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
})
export const hogFlowsPartialUpdateBodyNameMax = 400
+export const hogFlowsPartialUpdateBodyDescriptionDefault = ``
export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000
@@ -533,13 +681,15 @@ export const hogFlowsPartialUpdateBodyActionsItemFiltersOneSourceDefault = `even
export const hogFlowsPartialUpdateBodyActionsItemTypeMax = 100
export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsPartialUpdateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsPartialUpdateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsPartialUpdateBodyDescriptionDefault).describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -547,15 +697,24 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -563,17 +722,45 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
+ ),
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
),
- edges: zod.unknown().optional(),
actions: zod
.array(
zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsPartialUpdateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsPartialUpdateBodyActionsItemDescriptionDefault),
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsPartialUpdateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsPartialUpdateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
on_error: zod
.union([
zod
@@ -583,9 +770,12 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.object({
),
zod.null(),
])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
filters: zod
.union([
zod.object({
@@ -606,18 +796,38 @@ export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.object({
}),
zod.null(),
])
- .optional(),
- type: zod.string().max(hogFlowsPartialUpdateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsPartialUpdateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
})
)
- .optional(),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ .optional()
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
})
export const hogFlowsBatchJobsCreateBodyNameMax = 400
+export const hogFlowsBatchJobsCreateBodyDescriptionDefault = ``
export const hogFlowsBatchJobsCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsBatchJobsCreateBodyTriggerMaskingOneTtlMax = 94608000
@@ -628,13 +838,15 @@ export const hogFlowsBatchJobsCreateBodyActionsItemFiltersOneSourceDefault = `ev
export const hogFlowsBatchJobsCreateBodyActionsItemTypeMax = 100
export const HogFlowsBatchJobsCreateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsBatchJobsCreateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsBatchJobsCreateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsBatchJobsCreateBodyDescriptionDefault).describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -642,15 +854,24 @@ export const HogFlowsBatchJobsCreateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsBatchJobsCreateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsBatchJobsCreateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -658,152 +879,354 @@ export const HogFlowsBatchJobsCreateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
- ),
- edges: zod.unknown().optional(),
- actions: zod.array(
- zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsBatchJobsCreateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsBatchJobsCreateBodyActionsItemDescriptionDefault),
- on_error: zod
- .union([
- zod
- .enum(['continue', 'abort', 'complete', 'branch'])
- .describe(
- '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
- ),
- zod.null(),
- ])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
- .describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsBatchJobsCreateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- type: zod.string().max(hogFlowsBatchJobsCreateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
- })
- ),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
-})
-
-export const hogFlowsInvocationsCreateBodyNameMax = 400
-
-export const hogFlowsInvocationsCreateBodyTriggerMaskingOneTtlMin = 60
-export const hogFlowsInvocationsCreateBodyTriggerMaskingOneTtlMax = 94608000
-
-export const hogFlowsInvocationsCreateBodyActionsItemNameMax = 400
-
-export const hogFlowsInvocationsCreateBodyActionsItemDescriptionDefault = ``
-export const hogFlowsInvocationsCreateBodyActionsItemFiltersOneSourceDefault = `events`
-export const hogFlowsInvocationsCreateBodyActionsItemTypeMax = 100
-
-export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsInvocationsCreateBodyNameMax).nullish(),
- description: zod.string().optional(),
- status: zod
- .enum(['draft', 'active', 'archived'])
+ )
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
- trigger_masking: zod
- .union([
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
+ ),
+ edges: zod
+ .array(
zod.object({
- ttl: zod
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
.number()
- .min(hogFlowsInvocationsCreateBodyTriggerMaskingOneTtlMin)
- .max(hogFlowsInvocationsCreateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- conversion: zod.unknown().optional(),
- exit_condition: zod
- .enum([
- 'exit_on_conversion',
- 'exit_on_trigger_not_matched',
- 'exit_on_trigger_not_matched_or_conversion',
- 'exit_only_at_end',
- ])
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
.optional()
.describe(
- '\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
),
- edges: zod.unknown().optional(),
- actions: zod.array(
- zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsInvocationsCreateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsInvocationsCreateBodyActionsItemDescriptionDefault),
- on_error: zod
- .union([
- zod
- .enum(['continue', 'abort', 'complete', 'branch'])
- .describe(
- '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
- ),
- zod.null(),
- ])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsBatchJobsCreateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsBatchJobsCreateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
.describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsInvocationsCreateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- type: zod.string().max(hogFlowsInvocationsCreateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
+ '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsBatchJobsCreateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsBatchJobsCreateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
+})
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneNameMax = 400
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneDescriptionDefault = ``
+export const hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneDistinctIdMax = 200
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneFirstNameMax = 150
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneLastNameMax = 150
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneEmailMax = 254
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMin = 60
+export const hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMax = 94608000
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemNameMax = 400
+
+export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemDescriptionDefault = ``
+export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemFiltersOneSourceDefault = `events`
+export const hogFlowsInvocationsCreateBodyConfigurationOneActionsItemTypeMax = 100
+
+export const hogFlowsInvocationsCreateBodyMockAsyncFunctionsDefault = true
+
+export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
+ configuration: zod
+ .object({
+ id: zod.uuid(),
+ name: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneNameMax)
+ .nullish()
+ .describe('Workflow name.'),
+ description: zod
+ .string()
+ .default(hogFlowsInvocationsCreateBodyConfigurationOneDescriptionDefault)
+ .describe('Optional description.'),
+ version: zod.number(),
+ status: zod
+ .enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
+ .optional()
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
+ created_at: zod.iso.datetime({ offset: true }),
+ created_by: zod.object({
+ id: zod.number(),
+ uuid: zod.uuid(),
+ distinct_id: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneDistinctIdMax)
+ .nullish(),
+ first_name: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneFirstNameMax)
+ .optional(),
+ last_name: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneLastNameMax)
+ .optional(),
+ email: zod.email().max(hogFlowsInvocationsCreateBodyConfigurationOneCreatedByOneEmailMax),
+ is_email_verified: zod.boolean().nullish(),
+ hedgehog_config: zod.record(zod.string(), zod.unknown()).nullable(),
+ role_at_organization: zod
+ .union([
+ zod
+ .enum([
+ 'engineering',
+ 'data',
+ 'product',
+ 'founder',
+ 'leadership',
+ 'marketing',
+ 'sales',
+ 'other',
+ ])
+ .describe(
+ '\* `engineering` - Engineering\n\* `data` - Data\n\* `product` - Product Management\n\* `founder` - Founder\n\* `leadership` - Leadership\n\* `marketing` - Marketing\n\* `sales` - Sales \/ Success\n\* `other` - Other'
+ ),
+ zod.enum(['']),
+ zod.null(),
+ ])
+ .optional(),
+ }),
+ updated_at: zod.iso.datetime({ offset: true }),
+ trigger: zod.unknown(),
+ trigger_masking: zod
+ .union([
+ zod.object({
+ ttl: zod
+ .number()
+ .min(hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMin)
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneTriggerMaskingOneTtlMax)
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod
+ .number()
+ .nullish()
+ .describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
+ exit_condition: zod
+ .enum([
+ 'exit_on_conversion',
+ 'exit_on_trigger_not_matched',
+ 'exit_on_trigger_not_matched_or_conversion',
+ 'exit_only_at_end',
+ ])
+ .describe(
+ '\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
+ ),
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneActionsItemNameMax)
+ .describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsInvocationsCreateBodyConfigurationOneActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
+ .describe(
+ '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(
+ hogFlowsInvocationsCreateBodyConfigurationOneActionsItemFiltersOneSourceDefault
+ ),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsInvocationsCreateBodyConfigurationOneActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ abort_action: zod.string().nullable(),
+ variables: zod
+ .array(
+ zod
+ .record(zod.string(), zod.string())
+ .describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
+ billable_action_types: zod.unknown(),
})
- ),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ .optional()
+ .describe('Optional override; omit to use saved definition.'),
+ globals: zod
+ .record(zod.string(), zod.unknown())
+ .optional()
+ .describe('Test trigger payload, typically {event, person, groups}.'),
+ mock_async_functions: zod
+ .boolean()
+ .default(hogFlowsInvocationsCreateBodyMockAsyncFunctionsDefault)
+ .describe('True (default) mocks HTTP\/email\/SMS. False fires real side effects.'),
+ current_action_id: zod.string().optional().describe('Start from this action ID instead of the trigger.'),
})
export const hogFlowsSchedulesCreateBodyNameMax = 400
+export const hogFlowsSchedulesCreateBodyDescriptionDefault = ``
export const hogFlowsSchedulesCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsSchedulesCreateBodyTriggerMaskingOneTtlMax = 94608000
@@ -814,13 +1237,15 @@ export const hogFlowsSchedulesCreateBodyActionsItemFiltersOneSourceDefault = `ev
export const hogFlowsSchedulesCreateBodyActionsItemTypeMax = 100
export const HogFlowsSchedulesCreateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsSchedulesCreateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsSchedulesCreateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsSchedulesCreateBodyDescriptionDefault).describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -828,15 +1253,24 @@ export const HogFlowsSchedulesCreateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsSchedulesCreateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsSchedulesCreateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -844,59 +1278,111 @@ export const HogFlowsSchedulesCreateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
),
- edges: zod.unknown().optional(),
- actions: zod.array(
- zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsSchedulesCreateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsSchedulesCreateBodyActionsItemDescriptionDefault),
- on_error: zod
- .union([
- zod
- .enum(['continue', 'abort', 'complete', 'branch'])
- .describe(
- '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
- ),
- zod.null(),
- ])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsSchedulesCreateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsSchedulesCreateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
.describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsSchedulesCreateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- type: zod.string().max(hogFlowsSchedulesCreateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
- })
- ),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsSchedulesCreateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsSchedulesCreateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
})
export const hogFlowsSchedulesPartialUpdateBodyNameMax = 400
+export const hogFlowsSchedulesPartialUpdateBodyDescriptionDefault = ``
export const hogFlowsSchedulesPartialUpdateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsSchedulesPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000
@@ -907,13 +1393,18 @@ export const hogFlowsSchedulesPartialUpdateBodyActionsItemFiltersOneSourceDefaul
export const hogFlowsSchedulesPartialUpdateBodyActionsItemTypeMax = 100
export const HogFlowsSchedulesPartialUpdateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsSchedulesPartialUpdateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsSchedulesPartialUpdateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod
+ .string()
+ .default(hogFlowsSchedulesPartialUpdateBodyDescriptionDefault)
+ .describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -921,15 +1412,24 @@ export const HogFlowsSchedulesPartialUpdateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsSchedulesPartialUpdateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsSchedulesPartialUpdateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -937,17 +1437,45 @@ export const HogFlowsSchedulesPartialUpdateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
+ ),
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
),
- edges: zod.unknown().optional(),
actions: zod
.array(
zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsSchedulesPartialUpdateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsSchedulesPartialUpdateBodyActionsItemDescriptionDefault),
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsSchedulesPartialUpdateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsSchedulesPartialUpdateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
on_error: zod
.union([
zod
@@ -957,9 +1485,12 @@ export const HogFlowsSchedulesPartialUpdateBody = /* @__PURE__ */ zod.object({
),
zod.null(),
])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
filters: zod
.union([
zod.object({
@@ -980,18 +1511,38 @@ export const HogFlowsSchedulesPartialUpdateBody = /* @__PURE__ */ zod.object({
}),
zod.null(),
])
- .optional(),
- type: zod.string().max(hogFlowsSchedulesPartialUpdateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsSchedulesPartialUpdateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
})
)
- .optional(),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ .optional()
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
})
export const hogFlowsBulkDeleteCreateBodyNameMax = 400
+export const hogFlowsBulkDeleteCreateBodyDescriptionDefault = ``
export const hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMin = 60
export const hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMax = 94608000
@@ -1002,13 +1553,15 @@ export const hogFlowsBulkDeleteCreateBodyActionsItemFiltersOneSourceDefault = `e
export const hogFlowsBulkDeleteCreateBodyActionsItemTypeMax = 100
export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(hogFlowsBulkDeleteCreateBodyNameMax).nullish(),
- description: zod.string().optional(),
+ name: zod.string().max(hogFlowsBulkDeleteCreateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsBulkDeleteCreateBodyDescriptionDefault).describe('Optional description.'),
status: zod
.enum(['draft', 'active', 'archived'])
+ .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived')
.optional()
- .describe('\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'),
- trigger: zod.unknown().optional(),
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n\* `draft` - Draft\n\* `active` - Active\n\* `archived` - Archived'
+ ),
trigger_masking: zod
.union([
zod.object({
@@ -1016,15 +1569,24 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod.object({
.number()
.min(hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMin)
.max(hogFlowsBulkDeleteCreateBodyTriggerMaskingOneTtlMax)
- .nullish(),
- threshold: zod.number().nullish(),
- hash: zod.string(),
- bytecode: zod.unknown().optional(),
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M \/ 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
}),
zod.null(),
])
- .optional(),
- conversion: zod.unknown().optional(),
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion \/ exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
exit_condition: zod
.enum([
'exit_on_conversion',
@@ -1032,55 +1594,106 @@ export const HogFlowsBulkDeleteCreateBody = /* @__PURE__ */ zod.object({
'exit_on_trigger_not_matched_or_conversion',
'exit_only_at_end',
])
- .optional()
.describe(
'\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n\* `exit_on_conversion` - Conversion\n\* `exit_on_trigger_not_matched` - Trigger Not Matched\n\* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n\* `exit_only_at_end` - Only At End"
),
- edges: zod.unknown().optional(),
- actions: zod.array(
- zod.object({
- id: zod.string(),
- name: zod.string().max(hogFlowsBulkDeleteCreateBodyActionsItemNameMax),
- description: zod.string().default(hogFlowsBulkDeleteCreateBodyActionsItemDescriptionDefault),
- on_error: zod
- .union([
- zod
- .enum(['continue', 'abort', 'complete', 'branch'])
- .describe(
- '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
- ),
- zod.null(),
- ])
- .optional(),
- created_at: zod.number().optional(),
- updated_at: zod.number().optional(),
- filters: zod
- .union([
- zod.object({
- source: zod
- .enum(['events', 'person-updates', 'data-warehouse-table'])
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('\* `continue` - continue\n\* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n\* `continue` - continue\n\* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch \/ wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch \/ wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsBulkDeleteCreateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsBulkDeleteCreateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
.describe(
- '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
- )
- .default(hogFlowsBulkDeleteCreateBodyActionsItemFiltersOneSourceDefault),
- actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
- bytecode: zod.unknown().optional(),
- transpiled: zod.unknown().optional(),
- filter_test_accounts: zod.boolean().optional(),
- bytecode_error: zod.string().optional(),
- }),
- zod.null(),
- ])
- .optional(),
- type: zod.string().max(hogFlowsBulkDeleteCreateBodyActionsItemTypeMax),
- config: zod.unknown(),
- output_variable: zod.unknown().optional(),
- })
- ),
- variables: zod.array(zod.record(zod.string(), zod.string())).optional(),
+ '\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n\* `continue` - continue\n\* `abort` - abort\n\* `complete` - complete\n\* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '\* `events` - events\n\* `person-updates` - person-updates\n\* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsBulkDeleteCreateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsBulkDeleteCreateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function\*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
})
export const HogFlowsUserBlastRadiusCreateBody = /* @__PURE__ */ zod.object({
diff --git a/products/workflows/mcp/tools.yaml b/products/workflows/mcp/tools.yaml
index 02702bee6914..353188d333af 100644
--- a/products/workflows/mcp/tools.yaml
+++ b/products/workflows/mcp/tools.yaml
@@ -116,6 +116,23 @@ tools:
internal-hog-flows-user-blast-radius-persons-create:
operation: internal_hog_flows_user_blast_radius_persons_create
enabled: false
+ workflows-create:
+ operation: hog_flows_create
+ enabled: true
+ scopes:
+ - hog_flow:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: false
+ enrich_url: hog-{id}
+ title: Create workflow
+ description: >
+ Create a workflow. Requires an actions array with exactly one type='trigger' (config sets trigger type:
+ event|webhook|manual|batch|schedule|tracking_pixel). Other action types:
+ function/function_email/function_sms/function_push (CDP template), delay (e.g. '30m'), conditional_branch,
+ wait_until_condition. Connect via edges. Defaults to status='draft'; set 'active' to enable.
+ ui_app: workflow
workflows-get:
operation: hog_flows_retrieve
enabled: true
@@ -146,3 +163,34 @@ tools:
List all workflows in the project. Returns workflows with their name, description, status
(draft/active/archived), version, trigger configuration, and timestamps.
ui_app: workflow-list
+ workflows-run:
+ operation: hog_flows_invocations_create
+ enabled: true
+ scopes:
+ - hog_flow:write
+ annotations:
+ readOnly: false
+ destructive: true
+ idempotent: false
+ title: Test-run workflow
+ description: >
+ Test-invoke a saved workflow. Pass test event data via globals (typically {event, person, groups}). Async
+ actions (HTTP/email/SMS) are mocked by default; set mock_async_functions=false to fire real side effects.
+ Optional current_action_id starts from a specific node. Returns the execution trace.
+ exclude_params:
+ - configuration
+ workflows-update:
+ operation: hog_flows_partial_update
+ enabled: true
+ scopes:
+ - hog_flow:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ enrich_url: hog-{id}
+ title: Update workflow
+ description: Update a workflow by ID. Use workflows-enable / workflows-disable / workflows-archive to change status.
+ exclude_params:
+ - status
+ ui_app: workflow
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index a5608b7e929b..64c2f3b67352 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -5991,6 +5991,21 @@
"readOnlyHint": true
}
},
+ "workflows-create": {
+ "description": "Create a workflow. Requires an actions array with exactly one type='trigger' (config sets trigger type: event|webhook|manual|batch|schedule|tracking_pixel). Other action types: function/function_email/function_sms/function_push (CDP template), delay (e.g. '30m'), conditional_branch, wait_until_condition. Connect via edges. Defaults to status='draft'; set 'active' to enable.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Create workflow",
+ "title": "Create workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
"workflows-get": {
"description": "Get a specific workflow by ID. Returns the full workflow definition including trigger, edges, actions, exit condition, and variables.",
"category": "Workflows",
@@ -6020,5 +6035,35 @@
"openWorldHint": true,
"readOnlyHint": true
}
+ },
+ "workflows-run": {
+ "description": "Test-invoke a saved workflow. Pass test event data via globals (typically {event, person, groups}). Async actions (HTTP/email/SMS) are mocked by default; set mock_async_functions=false to fire real side effects. Optional current_action_id starts from a specific node. Returns the execution trace.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Test-run workflow",
+ "title": "Test-run workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-update": {
+ "description": "Update a workflow by ID. Use workflows-enable / workflows-disable / workflows-archive to change status.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Update workflow",
+ "title": "Update workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
}
}
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index b4051f5fa4c3..f0d1a71c5a72 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -6488,6 +6488,66 @@
"readOnlyHint": true
}
},
+ "workflows-archive": {
+ "description": "Archive a draft or disabled workflow.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Archive workflow",
+ "title": "Archive workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-create": {
+ "description": "Create a workflow. Requires an actions array with exactly one type='trigger' (config sets trigger type: event|webhook|manual|batch|schedule|tracking_pixel). Other action types: function/function_email/function_sms/function_push (CDP template), delay (e.g. '30m'), conditional_branch, wait_until_condition. Connect via edges. Defaults to status='draft'; set 'active' to enable.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Create workflow",
+ "title": "Create workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-disable": {
+ "description": "Disable / deactivate a live workflow and stop processing events. Confirm with the user before invoking.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Disable workflow",
+ "title": "Disable workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-enable": {
+ "description": "Enable / activate a draft workflow and start processing events. Confirm with the user before invoking.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Enable workflow",
+ "title": "Enable workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
"workflows-get": {
"description": "Get a specific workflow by ID. Returns the full workflow definition including trigger, edges, actions, exit condition, and variables.",
"category": "Workflows",
@@ -6517,5 +6577,35 @@
"openWorldHint": true,
"readOnlyHint": true
}
+ },
+ "workflows-run": {
+ "description": "Test-invoke a saved workflow. Pass test event data via globals (typically {event, person, groups}). Async actions (HTTP/email/SMS) are mocked by default; set mock_async_functions=false to fire real side effects. Optional current_action_id starts from a specific node. Returns the execution trace.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Test-run workflow",
+ "title": "Test-run workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-update": {
+ "description": "Update a workflow by ID. Use workflows-enable / workflows-disable / workflows-archive to change status.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Update workflow",
+ "title": "Update workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
}
}
diff --git a/services/mcp/schema/tool-definitions-v2.json b/services/mcp/schema/tool-definitions-v2.json
index 5c1e8b6bd320..c895c57166fc 100644
--- a/services/mcp/schema/tool-definitions-v2.json
+++ b/services/mcp/schema/tool-definitions-v2.json
@@ -43,5 +43,50 @@
"openWorldHint": true,
"readOnlyHint": true
}
+ },
+ "workflows-enable": {
+ "description": "Enable / activate a draft workflow and start processing events. Confirm with the user before invoking.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Enable workflow",
+ "title": "Enable workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-disable": {
+ "description": "Disable / deactivate a live workflow and stop processing events. Confirm with the user before invoking.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Disable workflow",
+ "title": "Disable workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
+ "workflows-archive": {
+ "description": "Archive a draft or disabled workflow.",
+ "category": "Workflows",
+ "feature": "workflows",
+ "summary": "Archive workflow",
+ "title": "Archive workflow",
+ "required_scopes": ["hog_flow:write"],
+ "new_mcp": true,
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
}
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 7901f2dc37d6..ac7bd3b2cc3d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -18517,6 +18517,9 @@ export namespace Schemas {
results: HeatmapResponseItem[];
}
+ /**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type HogFlowVariablesItem = {[key: string]: string};
/**
@@ -18535,17 +18538,49 @@ export namespace Schemas {
export interface HogFlowMasking {
/**
+ * Hash TTL in seconds (60 to ~94M / 3y).
* @minimum 60
* @maximum 94608000
* @nullable
*/
ttl?: number | null;
- /** @nullable */
+ /**
+ * Min matching events before triggering (k-anonymity).
+ * @nullable
+ */
threshold?: number | null;
+ /** HogQL template, e.g. '{person.properties.email}'. */
hash: string;
+ /** Auto-compiled from hash. Do not set. */
bytecode?: unknown;
}
+ /**
+ * * `continue` - continue
+ * `branch` - branch
+ */
+ export type HogFlowEdgeTypeEnum = typeof HogFlowEdgeTypeEnum[keyof typeof HogFlowEdgeTypeEnum];
+
+
+ export const HogFlowEdgeTypeEnum = {
+ Continue: 'continue',
+ Branch: 'branch',
+ } as const;
+
+ export interface HogFlowEdge {
+ /** Target action id. */
+ to: string;
+ /** continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].
+
+ * `continue` - continue
+ * `branch` - branch */
+ type: HogFlowEdgeTypeEnum;
+ /** Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition. */
+ index?: number;
+ /** Source action id. */
+ from: string;
+ }
+
/**
* * `continue` - continue
* `abort` - abort
@@ -18597,45 +18632,98 @@ export namespace Schemas {
}
export interface HogFlowAction {
+ /** Unique node ID within the workflow. */
id: string;
- /** @maxLength 400 */
+ /**
+ * Display name.
+ * @maxLength 400
+ */
name: string;
+ /** Optional description. */
description?: string;
+ /** On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).
+
+ * `continue` - continue
+ * `abort` - abort
+ * `complete` - complete
+ * `branch` - branch */
on_error?: OnErrorEnum | null;
+ /** Created at (epoch ms). Frontend-managed. */
created_at?: number;
+ /** Updated at (epoch ms). Frontend-managed. */
updated_at?: number;
+ /** Property filters gating this action. */
filters?: HogFunctionFilters | null;
- /** @maxLength 100 */
+ /**
+ * trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.
+ * @maxLength 100
+ */
type: string;
+ /** Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}. */
config: unknown;
+ /** Output variable definition for downstream actions. */
output_variable?: unknown;
}
export interface HogFlow {
readonly id: string;
/**
+ * Workflow name.
* @maxLength 400
* @nullable
*/
name?: string | null;
+ /** Optional description. */
description?: string;
readonly version: number;
+ /** draft (no execution), active (live), archived (disabled).
+
+ * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived */
status?: HogFlowStatusEnum;
readonly created_at: string;
readonly created_by: UserBasic;
readonly updated_at: string;
- trigger?: unknown;
+ readonly trigger: unknown;
+ /** Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable. */
trigger_masking?: HogFlowMasking | null;
+ /** Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */
conversion?: unknown;
+ /** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').
+
+ * `exit_on_conversion` - Conversion
+ * `exit_on_trigger_not_matched` - Trigger Not Matched
+ * `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion
+ * `exit_only_at_end` - Only At End */
exit_condition?: ExitConditionEnum;
- edges?: unknown;
+ /** Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise). */
+ edges?: HogFlowEdge[];
+ /** Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too. */
actions: HogFlowAction[];
/** @nullable */
readonly abort_action: string | null;
+ /** Workflow vars (key, type, default). Total <5KB. */
variables?: HogFlowVariablesItem[];
readonly billable_action_types: unknown;
}
+ /**
+ * Test trigger payload, typically {event, person, groups}.
+ */
+ export type HogFlowInvocationGlobals = { [key: string]: unknown };
+
+ export interface HogFlowInvocation {
+ /** Optional override; omit to use saved definition. */
+ configuration?: HogFlow;
+ /** Test trigger payload, typically {event, person, groups}. */
+ globals?: HogFlowInvocationGlobals;
+ /** True (default) mocks HTTP/email/SMS. False fires real side effects. */
+ mock_async_functions?: boolean;
+ /** Start from this action ID instead of the trigger. */
+ current_action_id?: string;
+ }
+
export interface HogFlowMinimal {
readonly id: string;
/** @nullable */
@@ -18691,6 +18779,9 @@ export namespace Schemas {
*/
export type HogFlowTemplateCreatedBy = { [key: string]: unknown } | null;
+ /**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type HogFlowTemplateVariablesItem = {[key: string]: string};
/**
@@ -28757,29 +28848,50 @@ export namespace Schemas {
readonly exception?: string | null;
}
+ /**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type PatchedHogFlowVariablesItem = {[key: string]: string};
export interface PatchedHogFlow {
readonly id?: string;
/**
+ * Workflow name.
* @maxLength 400
* @nullable
*/
name?: string | null;
+ /** Optional description. */
description?: string;
readonly version?: number;
+ /** draft (no execution), active (live), archived (disabled).
+
+ * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived */
status?: HogFlowStatusEnum;
readonly created_at?: string;
readonly created_by?: UserBasic;
readonly updated_at?: string;
- trigger?: unknown;
+ readonly trigger?: unknown;
+ /** Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable. */
trigger_masking?: HogFlowMasking | null;
+ /** Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side. */
conversion?: unknown;
+ /** exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').
+
+ * `exit_on_conversion` - Conversion
+ * `exit_on_trigger_not_matched` - Trigger Not Matched
+ * `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion
+ * `exit_only_at_end` - Only At End */
exit_condition?: ExitConditionEnum;
- edges?: unknown;
+ /** Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise). */
+ edges?: HogFlowEdge[];
+ /** Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too. */
actions?: HogFlowAction[];
/** @nullable */
readonly abort_action?: string | null;
+ /** Workflow vars (key, type, default). Total <5KB. */
variables?: PatchedHogFlowVariablesItem[];
readonly billable_action_types?: unknown;
}
@@ -28789,6 +28901,9 @@ export namespace Schemas {
*/
export type PatchedHogFlowTemplateCreatedBy = { [key: string]: unknown } | null;
+ /**
+ * Variable: {key, type: string|number|boolean, default}.
+ */
export type PatchedHogFlowTemplateVariablesItem = {[key: string]: string};
/**
@@ -41253,9 +41368,24 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: EnvironmentsHogFlowsListStatus;
updated_at?: string;
};
+ export type EnvironmentsHogFlowsListStatus = typeof EnvironmentsHogFlowsListStatus[keyof typeof EnvironmentsHogFlowsListStatus];
+
+
+ export const EnvironmentsHogFlowsListStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+ } as const;
+
export type EnvironmentsHogFlowsLogsRetrieveParams = {
/**
* Only return entries after this ISO 8601 timestamp.
@@ -41424,9 +41554,24 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: EnvironmentsHogFlowsSchedulesListStatus;
updated_at?: string;
};
+ export type EnvironmentsHogFlowsSchedulesListStatus = typeof EnvironmentsHogFlowsSchedulesListStatus[keyof typeof EnvironmentsHogFlowsSchedulesListStatus];
+
+
+ export const EnvironmentsHogFlowsSchedulesListStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+ } as const;
+
export type EnvironmentsHogFlowsSchedulesCreateParams = {
created_at?: string;
created_by?: number;
@@ -41439,9 +41584,24 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: EnvironmentsHogFlowsSchedulesCreateStatus;
updated_at?: string;
};
+ export type EnvironmentsHogFlowsSchedulesCreateStatus = typeof EnvironmentsHogFlowsSchedulesCreateStatus[keyof typeof EnvironmentsHogFlowsSchedulesCreateStatus];
+
+
+ export const EnvironmentsHogFlowsSchedulesCreateStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+ } as const;
+
export type EnvironmentsHogFunctionsListParams = {
created_at?: string;
created_by?: number;
@@ -46627,9 +46787,24 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: HogFlowsListStatus;
updated_at?: string;
};
+ export type HogFlowsListStatus = typeof HogFlowsListStatus[keyof typeof HogFlowsListStatus];
+
+
+ export const HogFlowsListStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+ } as const;
+
export type HogFlowsLogsRetrieveParams = {
/**
* Only return entries after this ISO 8601 timestamp.
@@ -46798,9 +46973,24 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: HogFlowsSchedulesListStatus;
updated_at?: string;
};
+ export type HogFlowsSchedulesListStatus = typeof HogFlowsSchedulesListStatus[keyof typeof HogFlowsSchedulesListStatus];
+
+
+ export const HogFlowsSchedulesListStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+ } as const;
+
export type HogFlowsSchedulesCreateParams = {
created_at?: string;
created_by?: number;
@@ -46813,9 +47003,24 @@ export namespace Schemas {
* The initial index from which to return the results.
*/
offset?: number;
+ /**
+ * * `draft` - Draft
+ * `active` - Active
+ * `archived` - Archived
+ */
+ status?: HogFlowsSchedulesCreateStatus;
updated_at?: string;
};
+ export type HogFlowsSchedulesCreateStatus = typeof HogFlowsSchedulesCreateStatus[keyof typeof HogFlowsSchedulesCreateStatus];
+
+
+ export const HogFlowsSchedulesCreateStatus = {
+ Active: 'active',
+ Archived: 'archived',
+ Draft: 'draft',
+ } as const;
+
export type HogFunctionTemplatesListParams = {
/**
* Number of results to return per page.
diff --git a/services/mcp/src/generated/workflows/api.ts b/services/mcp/src/generated/workflows/api.ts
index 0687fb616120..07b1e407cca1 100644
--- a/services/mcp/src/generated/workflows/api.ts
+++ b/services/mcp/src/generated/workflows/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 4 enabled ops
+ * PostHog API - MCP 7 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -22,9 +22,177 @@ export const HogFlowsListQueryParams = /* @__PURE__ */ zod.object({
id: zod.string().optional(),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
+ status: zod
+ .enum(['active', 'archived', 'draft'])
+ .optional()
+ .describe('* `draft` - Draft\n* `active` - Active\n* `archived` - Archived'),
updated_at: zod.iso.datetime({ offset: true }).optional(),
})
+export const HogFlowsCreateParams = /* @__PURE__ */ zod.object({
+ 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 hogFlowsCreateBodyNameMax = 400
+
+export const hogFlowsCreateBodyDescriptionDefault = ``
+export const hogFlowsCreateBodyTriggerMaskingOneTtlMin = 60
+export const hogFlowsCreateBodyTriggerMaskingOneTtlMax = 94608000
+
+export const hogFlowsCreateBodyActionsItemNameMax = 400
+
+export const hogFlowsCreateBodyActionsItemDescriptionDefault = ``
+export const hogFlowsCreateBodyActionsItemFiltersOneSourceDefault = `events`
+export const hogFlowsCreateBodyActionsItemTypeMax = 100
+
+export const HogFlowsCreateBody = /* @__PURE__ */ zod.object({
+ name: zod.string().max(hogFlowsCreateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().default(hogFlowsCreateBodyDescriptionDefault).describe('Optional description.'),
+ status: zod
+ .enum(['draft', 'active', 'archived'])
+ .describe('* `draft` - Draft\n* `active` - Active\n* `archived` - Archived')
+ .optional()
+ .describe(
+ 'draft (no execution), active (live), archived (disabled).\n\n* `draft` - Draft\n* `active` - Active\n* `archived` - Archived'
+ ),
+ trigger_masking: zod
+ .union([
+ zod.object({
+ ttl: zod
+ .number()
+ .min(hogFlowsCreateBodyTriggerMaskingOneTtlMin)
+ .max(hogFlowsCreateBodyTriggerMaskingOneTtlMax)
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M / 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
+ exit_condition: zod
+ .enum([
+ 'exit_on_conversion',
+ 'exit_on_trigger_not_matched',
+ 'exit_on_trigger_not_matched_or_conversion',
+ 'exit_only_at_end',
+ ])
+ .describe(
+ '* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End"
+ ),
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('* `continue` - continue\n* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n* `continue` - continue\n* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsCreateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsCreateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
+ .describe(
+ '* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsCreateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsCreateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
+})
+
export const HogFlowsRetrieveParams = /* @__PURE__ */ zod.object({
id: zod.string().describe('A UUID string identifying this hog flow.'),
project_id: zod
@@ -34,6 +202,187 @@ export const HogFlowsRetrieveParams = /* @__PURE__ */ zod.object({
),
})
+export const HogFlowsPartialUpdateParams = /* @__PURE__ */ zod.object({
+ id: zod.string().describe('A UUID string identifying this hog flow.'),
+ 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 hogFlowsPartialUpdateBodyNameMax = 400
+
+export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin = 60
+export const hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax = 94608000
+
+export const hogFlowsPartialUpdateBodyActionsItemNameMax = 400
+
+export const hogFlowsPartialUpdateBodyActionsItemDescriptionDefault = ``
+export const hogFlowsPartialUpdateBodyActionsItemFiltersOneSourceDefault = `events`
+export const hogFlowsPartialUpdateBodyActionsItemTypeMax = 100
+
+export const HogFlowsPartialUpdateBody = /* @__PURE__ */ zod.object({
+ name: zod.string().max(hogFlowsPartialUpdateBodyNameMax).nullish().describe('Workflow name.'),
+ description: zod.string().optional().describe('Optional description.'),
+ trigger_masking: zod
+ .union([
+ zod.object({
+ ttl: zod
+ .number()
+ .min(hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMin)
+ .max(hogFlowsPartialUpdateBodyTriggerMaskingOneTtlMax)
+ .nullish()
+ .describe('Hash TTL in seconds (60 to ~94M / 3y).'),
+ threshold: zod.number().nullish().describe('Min matching events before triggering (k-anonymity).'),
+ hash: zod.string().describe("HogQL template, e.g. '{person.properties.email}'."),
+ bytecode: zod.unknown().optional().describe('Auto-compiled from hash. Do not set.'),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable.'
+ ),
+ conversion: zod
+ .unknown()
+ .optional()
+ .describe(
+ 'Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side.'
+ ),
+ exit_condition: zod
+ .enum([
+ 'exit_on_conversion',
+ 'exit_on_trigger_not_matched',
+ 'exit_on_trigger_not_matched_or_conversion',
+ 'exit_only_at_end',
+ ])
+ .describe(
+ '* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End'
+ )
+ .optional()
+ .describe(
+ "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End"
+ ),
+ edges: zod
+ .array(
+ zod.object({
+ to: zod.string().describe('Target action id.'),
+ type: zod
+ .enum(['continue', 'branch'])
+ .describe('* `continue` - continue\n* `branch` - branch')
+ .describe(
+ "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n* `continue` - continue\n* `branch` - branch"
+ ),
+ index: zod
+ .number()
+ .optional()
+ .describe(
+ "Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition."
+ ),
+ from: zod.string().describe('Source action id.'),
+ })
+ )
+ .optional()
+ .describe(
+ "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise)."
+ ),
+ actions: zod
+ .array(
+ zod.object({
+ id: zod.string().describe('Unique node ID within the workflow.'),
+ name: zod.string().max(hogFlowsPartialUpdateBodyActionsItemNameMax).describe('Display name.'),
+ description: zod
+ .string()
+ .default(hogFlowsPartialUpdateBodyActionsItemDescriptionDefault)
+ .describe('Optional description.'),
+ on_error: zod
+ .union([
+ zod
+ .enum(['continue', 'abort', 'complete', 'branch'])
+ .describe(
+ '* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch'
+ ),
+ created_at: zod.number().optional().describe('Created at (epoch ms). Frontend-managed.'),
+ updated_at: zod.number().optional().describe('Updated at (epoch ms). Frontend-managed.'),
+ filters: zod
+ .union([
+ zod.object({
+ source: zod
+ .enum(['events', 'person-updates', 'data-warehouse-table'])
+ .describe(
+ '* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table'
+ )
+ .default(hogFlowsPartialUpdateBodyActionsItemFiltersOneSourceDefault),
+ actions: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ events: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ data_warehouse: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ properties: zod.array(zod.record(zod.string(), zod.unknown())).optional(),
+ bytecode: zod.unknown().optional(),
+ transpiled: zod.unknown().optional(),
+ filter_test_accounts: zod.boolean().optional(),
+ bytecode_error: zod.string().optional(),
+ }),
+ zod.null(),
+ ])
+ .optional()
+ .describe('Property filters gating this action.'),
+ type: zod
+ .string()
+ .max(hogFlowsPartialUpdateBodyActionsItemTypeMax)
+ .describe(
+ 'trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.'
+ ),
+ config: zod
+ .unknown()
+ .describe(
+ "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ ),
+ output_variable: zod
+ .unknown()
+ .optional()
+ .describe('Output variable definition for downstream actions.'),
+ })
+ )
+ .optional()
+ .describe("Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too."),
+ variables: zod
+ .array(
+ zod.record(zod.string(), zod.string()).describe('Variable: {key, type: string|number|boolean, default}.')
+ )
+ .optional()
+ .describe('Workflow vars (key, type, default). Total <5KB.'),
+})
+
+export const HogFlowsInvocationsCreateParams = /* @__PURE__ */ zod.object({
+ id: zod.string().describe('A UUID string identifying this hog flow.'),
+ 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 hogFlowsInvocationsCreateBodyMockAsyncFunctionsDefault = true
+
+export const HogFlowsInvocationsCreateBody = /* @__PURE__ */ zod.object({
+ globals: zod
+ .record(zod.string(), zod.unknown())
+ .optional()
+ .describe('Test trigger payload, typically {event, person, groups}.'),
+ mock_async_functions: zod
+ .boolean()
+ .default(hogFlowsInvocationsCreateBodyMockAsyncFunctionsDefault)
+ .describe('True (default) mocks HTTP/email/SMS. False fires real side effects.'),
+ current_action_id: zod.string().optional().describe('Start from this action ID instead of the trigger.'),
+})
+
export const HogFlowsLogsRetrieveParams = /* @__PURE__ */ zod.object({
id: zod.string().describe('A UUID string identifying this hog flow.'),
project_id: zod
diff --git a/services/mcp/src/tools/generated/workflows.ts b/services/mcp/src/tools/generated/workflows.ts
index e8743741d548..1ad64d58e826 100644
--- a/services/mcp/src/tools/generated/workflows.ts
+++ b/services/mcp/src/tools/generated/workflows.ts
@@ -3,11 +3,16 @@ import { z } from 'zod'
import type { Schemas } from '@/api/generated'
import {
+ HogFlowsCreateBody,
+ HogFlowsInvocationsCreateBody,
+ HogFlowsInvocationsCreateParams,
HogFlowsListQueryParams,
HogFlowsLogsRetrieveParams,
HogFlowsLogsRetrieveQueryParams,
HogFlowsMetricsRetrieveParams,
HogFlowsMetricsRetrieveQueryParams,
+ HogFlowsPartialUpdateBody,
+ HogFlowsPartialUpdateParams,
HogFlowsRetrieveParams,
} from '@/generated/workflows/api'
import { withUiApp } from '@/resources/ui-apps'
@@ -65,6 +70,51 @@ const hogFlowsMetricsRetrieve = (): ToolBase<typeof HogFlowsMetricsRetrieveSchem
},
})
+const WorkflowsCreateSchema = HogFlowsCreateBody
+
+const workflowsCreate = (): ToolBase<typeof WorkflowsCreateSchema, WithPostHogUrl<Schemas.HogFlow>> =>
+ withUiApp('workflow', {
+ name: 'workflows-create',
+ schema: WorkflowsCreateSchema,
+ handler: async (context: Context, params: z.infer<typeof WorkflowsCreateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.name !== undefined) {
+ body['name'] = params.name
+ }
+ if (params.description !== undefined) {
+ body['description'] = params.description
+ }
+ if (params.status !== undefined) {
+ body['status'] = params.status
+ }
+ if (params.trigger_masking !== undefined) {
+ body['trigger_masking'] = params.trigger_masking
+ }
+ if (params.conversion !== undefined) {
+ body['conversion'] = params.conversion
+ }
+ if (params.exit_condition !== undefined) {
+ body['exit_condition'] = params.exit_condition
+ }
+ if (params.edges !== undefined) {
+ body['edges'] = params.edges
+ }
+ if (params.actions !== undefined) {
+ body['actions'] = params.actions
+ }
+ if (params.variables !== undefined) {
+ body['variables'] = params.variables
+ }
+ const result = await context.api.request<Schemas.HogFlow>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/`,
+ body,
+ })
+ return await withPostHogUrl(context, result, `/pipeline/destinations/hog-${result.id}`)
+ },
+ })
+
const WorkflowsGetSchema = HogFlowsRetrieveParams.omit({ project_id: true })
const workflowsGet = (): ToolBase<typeof WorkflowsGetSchema, WithPostHogUrl<Schemas.HogFlow>> =>
@@ -98,6 +148,7 @@ const workflowsList = (): ToolBase<typeof WorkflowsListSchema, WithPostHogUrl<Sc
id: params.id,
limit: params.limit,
offset: params.offset,
+ status: params.status,
updated_at: params.updated_at,
},
})
@@ -105,9 +156,84 @@ const workflowsList = (): ToolBase<typeof WorkflowsListSchema, WithPostHogUrl<Sc
},
})
+const WorkflowsRunSchema = HogFlowsInvocationsCreateParams.omit({ project_id: true }).extend(
+ HogFlowsInvocationsCreateBody.shape
+)
+
+const workflowsRun = (): ToolBase<typeof WorkflowsRunSchema, unknown> => ({
+ name: 'workflows-run',
+ schema: WorkflowsRunSchema,
+ handler: async (context: Context, params: z.infer<typeof WorkflowsRunSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.globals !== undefined) {
+ body['globals'] = params.globals
+ }
+ if (params.mock_async_functions !== undefined) {
+ body['mock_async_functions'] = params.mock_async_functions
+ }
+ if (params.current_action_id !== undefined) {
+ body['current_action_id'] = params.current_action_id
+ }
+ const result = await context.api.request<unknown>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/invocations/`,
+ body,
+ })
+ return result
+ },
+})
+
+const WorkflowsUpdateSchema = HogFlowsPartialUpdateParams.omit({ project_id: true }).extend(
+ HogFlowsPartialUpdateBody.shape
+)
+
+const workflowsUpdate = (): ToolBase<typeof WorkflowsUpdateSchema, WithPostHogUrl<Schemas.HogFlow>> =>
+ withUiApp('workflow', {
+ name: 'workflows-update',
+ schema: WorkflowsUpdateSchema,
+ handler: async (context: Context, params: z.infer<typeof WorkflowsUpdateSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.name !== undefined) {
+ body['name'] = params.name
+ }
+ if (params.description !== undefined) {
+ body['description'] = params.description
+ }
+ if (params.trigger_masking !== undefined) {
+ body['trigger_masking'] = params.trigger_masking
+ }
+ if (params.conversion !== undefined) {
+ body['conversion'] = params.conversion
+ }
+ if (params.exit_condition !== undefined) {
+ body['exit_condition'] = params.exit_condition
+ }
+ if (params.edges !== undefined) {
+ body['edges'] = params.edges
+ }
+ if (params.actions !== undefined) {
+ body['actions'] = params.actions
+ }
+ if (params.variables !== undefined) {
+ body['variables'] = params.variables
+ }
+ const result = await context.api.request<Schemas.HogFlow>({
+ method: 'PATCH',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/`,
+ body,
+ })
+ return await withPostHogUrl(context, result, `/pipeline/destinations/hog-${result.id}`)
+ },
+ })
+
export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'hog-flows-logs-retrieve': hogFlowsLogsRetrieve,
'hog-flows-metrics-retrieve': hogFlowsMetricsRetrieve,
+ 'workflows-create': workflowsCreate,
'workflows-get': workflowsGet,
'workflows-list': workflowsList,
+ 'workflows-run': workflowsRun,
+ 'workflows-update': workflowsUpdate,
}
diff --git a/services/mcp/src/tools/index.ts b/services/mcp/src/tools/index.ts
index 890f90ed1f02..f5af2269f7e9 100644
--- a/services/mcp/src/tools/index.ts
+++ b/services/mcp/src/tools/index.ts
@@ -48,6 +48,8 @@ import {
getToolDefinition,
} from './toolDefinitions'
import type { Context, Tool, ToolBase, ZodObjectAny } from './types'
+// Workflows (lifecycle — CRUD lives in generated/workflows.ts)
+import { workflowsArchive, workflowsDisable, workflowsEnable } from './workflows/lifecycle'
// Map of tool names to tool factory functions
export const TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> = {
@@ -102,6 +104,12 @@ export const TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> = {
'external-data-sources-db-schema': externalDataSourcesDbSchema,
'external-data-sources-jobs': externalDataSourcesJobs,
'external-data-sync-logs': externalDataSyncLogs,
+
+ // Workflows lifecycle (thin wrappers over hog_flows_partial_update so MCP gets
+ // an idiomatic enable/disable/archive surface without three new REST endpoints).
+ 'workflows-enable': workflowsEnable,
+ 'workflows-disable': workflowsDisable,
+ 'workflows-archive': workflowsArchive,
}
export const getToolsFromContext = async (
diff --git a/services/mcp/src/tools/workflows/lifecycle.ts b/services/mcp/src/tools/workflows/lifecycle.ts
new file mode 100644
index 000000000000..0503f17911fa
--- /dev/null
+++ b/services/mcp/src/tools/workflows/lifecycle.ts
@@ -0,0 +1,47 @@
+import { z } from 'zod'
+
+import type { Schemas } from '@/api/generated'
+import { HogFlowsPartialUpdateParams } from '@/generated/workflows/api'
+import { withUiApp } from '@/resources/ui-apps'
+import { withPostHogUrl, type WithPostHogUrl } from '@/tools/tool-utils'
+import type { Context, ToolBase } from '@/tools/types'
+
+const LifecycleSchema = HogFlowsPartialUpdateParams.omit({ project_id: true })
+
+type LifecycleParams = z.infer<typeof LifecycleSchema>
+type LifecycleResult = WithPostHogUrl<Schemas.HogFlow>
+
+const patchStatus = async (
+ context: Context,
+ params: LifecycleParams,
+ status: 'active' | 'draft' | 'archived'
+): Promise<LifecycleResult> => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.HogFlow>({
+ method: 'PATCH',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/`,
+ body: { status },
+ })
+ return await withPostHogUrl(context, result, `/pipeline/destinations/hog-${result.id}`)
+}
+
+export const workflowsEnable = (): ToolBase<typeof LifecycleSchema, LifecycleResult> =>
+ withUiApp('workflow', {
+ name: 'workflows-enable',
+ schema: LifecycleSchema,
+ handler: (context, params) => patchStatus(context, params, 'active'),
+ })
+
+export const workflowsDisable = (): ToolBase<typeof LifecycleSchema, LifecycleResult> =>
+ withUiApp('workflow', {
+ name: 'workflows-disable',
+ schema: LifecycleSchema,
+ handler: (context, params) => patchStatus(context, params, 'draft'),
+ })
+
+export const workflowsArchive = (): ToolBase<typeof LifecycleSchema, LifecycleResult> =>
+ withUiApp('workflow', {
+ name: 'workflows-archive',
+ schema: LifecycleSchema,
+ handler: (context, params) => patchStatus(context, params, 'archived'),
+ })
diff --git a/services/mcp/tests/tools/workflows.integration.test.ts b/services/mcp/tests/tools/workflows.integration.test.ts
index b90fecd02397..d7a1d7db527a 100644
--- a/services/mcp/tests/tools/workflows.integration.test.ts
+++ b/services/mcp/tests/tools/workflows.integration.test.ts
@@ -1,24 +1,33 @@
-import { beforeAll, describe, expect, it } from 'vitest'
+import { afterEach, beforeAll, describe, expect, it } from 'vitest'
import {
TEST_ORG_ID,
TEST_PROJECT_ID,
createTestClient,
createTestContext,
+ generateUniqueKey,
parseToolResponse,
setActiveProjectAndOrg,
validateEnvironmentVariables,
} from '@/shared/test-utils'
import { GENERATED_TOOLS } from '@/tools/generated/workflows'
import type { Context } from '@/tools/types'
+import { workflowsArchive, workflowsDisable, workflowsEnable } from '@/tools/workflows/lifecycle'
describe('Workflows', { concurrent: false }, () => {
let context: Context
const listTool = GENERATED_TOOLS['workflows-list']!()
const getTool = GENERATED_TOOLS['workflows-get']!()
+ const createTool = GENERATED_TOOLS['workflows-create']!()
+ const updateTool = GENERATED_TOOLS['workflows-update']!()
const logsTool = GENERATED_TOOLS['hog-flows-logs-retrieve']!()
const metricsTool = GENERATED_TOOLS['hog-flows-metrics-retrieve']!()
+ const enableTool = workflowsEnable()
+ const disableTool = workflowsDisable()
+ const archiveTool = workflowsArchive()
+
+ const createdWorkflowIds: string[] = []
beforeAll(async () => {
validateEnvironmentVariables()
@@ -27,6 +36,52 @@ describe('Workflows', { concurrent: false }, () => {
await setActiveProjectAndOrg(context, TEST_PROJECT_ID!, TEST_ORG_ID!)
})
+ afterEach(async () => {
+ // Hard delete is intentionally not exposed as an MCP tool, but the underlying API
+ // endpoint still exists. Call it directly for teardown so we actually remove the rows
+ // instead of leaving archived workflows behind in the shared integration env.
+ const projectId = await context.stateManager.getProjectId()
+ for (const id of createdWorkflowIds) {
+ try {
+ await context.api.request({
+ method: 'DELETE',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(id)}/`,
+ })
+ } catch {
+ // Best effort — workflow may already be gone
+ }
+ }
+ createdWorkflowIds.length = 0
+ })
+
+ function makeWorkflowParams(overrides: Record<string, unknown> = {}): Record<string, unknown> {
+ const ts = Date.now()
+ return {
+ name: `mcp-test-${generateUniqueKey('wf')}`,
+ status: 'draft',
+ actions: [
+ {
+ id: 'trigger_node',
+ name: 'Trigger',
+ type: 'trigger',
+ created_at: ts,
+ updated_at: ts,
+ config: { type: 'event', filters: { events: [] } },
+ },
+ {
+ id: 'exit_node',
+ name: 'Exit',
+ type: 'exit',
+ created_at: ts,
+ updated_at: ts,
+ config: { reason: 'Default exit' },
+ },
+ ],
+ edges: [{ from: 'trigger_node', to: 'exit_node', type: 'continue' }],
+ ...overrides,
+ }
+ }
+
describe('workflows-list tool', () => {
it('should list workflows and return paginated structure', async () => {
const result = await listTool.handler(context, {})
@@ -166,4 +221,111 @@ describe('Workflows', { concurrent: false }, () => {
await expect(metricsTool.handler(context, { id: absentId })).rejects.toThrow()
})
})
+
+ describe('workflows-create tool', () => {
+ it('should create a draft workflow with one trigger and one exit', async () => {
+ const params = makeWorkflowParams()
+ const result = await createTool.handler(context, params)
+ const workflow = parseToolResponse(result)
+ createdWorkflowIds.push(workflow.id)
+
+ expect(workflow.id).toBeTypeOf('string')
+ expect(workflow.name).toBe(params.name)
+ expect(workflow.status).toBe('draft')
+ expect(workflow.version).toBeTypeOf('number')
+ expect(Array.isArray(workflow.actions)).toBe(true)
+ expect(workflow.actions).toHaveLength(2)
+ expect(workflow._posthogUrl).toContain(`/pipeline/destinations/hog-${workflow.id}`)
+ })
+
+ it('should reject a workflow without exactly one trigger action', async () => {
+ const params = makeWorkflowParams({
+ actions: [
+ {
+ id: 'exit_node',
+ name: 'Exit',
+ type: 'exit',
+ config: { reason: 'Default exit' },
+ },
+ ],
+ edges: [],
+ })
+ await expect(createTool.handler(context, params)).rejects.toThrow()
+ })
+ })
+
+ describe('workflows-update tool', () => {
+ it('should partially update a workflow name', async () => {
+ const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))
+ createdWorkflowIds.push(created.id)
+
+ const renamed = parseToolResponse(
+ await updateTool.handler(context, { id: created.id, name: 'mcp-test-renamed' })
+ )
+
+ expect(renamed.id).toBe(created.id)
+ expect(renamed.name).toBe('mcp-test-renamed')
+ })
+ })
+
+ // workflows-run hits the invocations endpoint, which forwards to the CDP plugin
+ // server (CDP_API_URL). That container isn't started in MCP CI (only the `temporal`
+ // compose profile is enabled), so the happy-path returns 500 from a DNS failure.
+ // Coverage for the endpoint lives in posthog/api/test/test_hog_flow.py
+ // (test_can_call_a_test_invocation) with CDP mocked, and at the MCP unit layer
+ // (tests/unit/workflows-run-handler.test.ts) for the handler wiring.
+
+ describe('workflows-enable / disable / archive tools', () => {
+ it('should enable a draft workflow', async () => {
+ const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))
+ createdWorkflowIds.push(created.id)
+ expect(created.status).toBe('draft')
+
+ const enabled = parseToolResponse(await enableTool.handler(context, { id: created.id }))
+ expect(enabled.status).toBe('active')
+ })
+
+ it('should disable a live workflow back to draft', async () => {
+ const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))
+ createdWorkflowIds.push(created.id)
+
+ await enableTool.handler(context, { id: created.id })
+ const disabled = parseToolResponse(await disableTool.handler(context, { id: created.id }))
+ expect(disabled.status).toBe('draft')
+ })
+
+ it('should archive a draft workflow', async () => {
+ const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))
+ createdWorkflowIds.push(created.id)
+
+ const archived = parseToolResponse(await archiveTool.handler(context, { id: created.id }))
+ expect(archived.status).toBe('archived')
+ })
+
+ it('should treat enabling an already-active workflow as a no-op', async () => {
+ const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))
+ createdWorkflowIds.push(created.id)
+
+ await enableTool.handler(context, { id: created.id })
+ const reEnabled = parseToolResponse(await enableTool.handler(context, { id: created.id }))
+ expect(reEnabled.status).toBe('active')
+ })
+ })
+
+ describe('full lifecycle', () => {
+ it('should create → enable → disable → archive', async () => {
+ const created = parseToolResponse(await createTool.handler(context, makeWorkflowParams()))
+ const id = created.id
+ createdWorkflowIds.push(id)
+
+ const enabled = parseToolResponse(await enableTool.handler(context, { id }))
+ expect(enabled.status).toBe('active')
+
+ const disabled = parseToolResponse(await disableTool.handler(context, { id }))
+ expect(disabled.status).toBe('draft')
+
+ const archived = parseToolResponse(await archiveTool.handler(context, { id }))
+ expect(archived.status).toBe('archived')
+ })
+ })
})
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-create.json
new file mode 100644
index 000000000000..84fd0bc856c2
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-create.json
@@ -0,0 +1,251 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "actions": {
+ "description": "Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too.",
+ "items": {
+ "properties": {
+ "config": {
+ "description": "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ },
+ "created_at": {
+ "description": "Created at (epoch ms). Frontend-managed.",
+ "type": "number"
+ },
+ "description": {
+ "default": "",
+ "description": "Optional description.",
+ "type": "string"
+ },
+ "filters": {
+ "anyOf": [
+ {
+ "properties": {
+ "actions": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "bytecode": {},
+ "bytecode_error": {
+ "type": "string"
+ },
+ "data_warehouse": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "events": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "filter_test_accounts": {
+ "type": "boolean"
+ },
+ "properties": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "source": {
+ "default": "events",
+ "description": "* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table",
+ "enum": ["events", "person-updates", "data-warehouse-table"],
+ "type": "string"
+ },
+ "transpiled": {}
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Property filters gating this action."
+ },
+ "id": {
+ "description": "Unique node ID within the workflow.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Display name.",
+ "maxLength": 400,
+ "type": "string"
+ },
+ "on_error": {
+ "anyOf": [
+ {
+ "description": "* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch",
+ "enum": ["continue", "abort", "complete", "branch"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch"
+ },
+ "output_variable": {
+ "description": "Output variable definition for downstream actions."
+ },
+ "type": {
+ "description": "trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.",
+ "maxLength": 100,
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "Updated at (epoch ms). Frontend-managed.",
+ "type": "number"
+ }
+ },
+ "required": ["id", "name", "type", "config"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "conversion": {
+ "description": "Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
+ },
+ "description": {
+ "default": "",
+ "description": "Optional description.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise).",
+ "items": {
+ "properties": {
+ "from": {
+ "description": "Source action id.",
+ "type": "string"
+ },
+ "index": {
+ "description": "Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition.",
+ "type": "number"
+ },
+ "to": {
+ "description": "Target action id.",
+ "type": "string"
+ },
+ "type": {
+ "description": "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n* `continue` - continue\n* `branch` - branch",
+ "enum": ["continue", "branch"],
+ "type": "string"
+ }
+ },
+ "required": ["to", "type", "from"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "exit_condition": {
+ "description": "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End",
+ "enum": [
+ "exit_on_conversion",
+ "exit_on_trigger_not_matched",
+ "exit_on_trigger_not_matched_or_conversion",
+ "exit_only_at_end"
+ ],
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Workflow name."
+ },
+ "status": {
+ "description": "draft (no execution), active (live), archived (disabled).\n\n* `draft` - Draft\n* `active` - Active\n* `archived` - Archived",
+ "enum": ["draft", "active", "archived"],
+ "type": "string"
+ },
+ "trigger_masking": {
+ "anyOf": [
+ {
+ "properties": {
+ "bytecode": {
+ "description": "Auto-compiled from hash. Do not set."
+ },
+ "hash": {
+ "description": "HogQL template, e.g. '{person.properties.email}'.",
+ "type": "string"
+ },
+ "threshold": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Min matching events before triggering (k-anonymity)."
+ },
+ "ttl": {
+ "anyOf": [
+ {
+ "maximum": 94608000,
+ "minimum": 60,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Hash TTL in seconds (60 to ~94M / 3y)."
+ }
+ },
+ "required": ["hash"],
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable."
+ },
+ "variables": {
+ "description": "Workflow vars (key, type, default). Total <5KB.",
+ "items": {
+ "additionalProperties": {
+ "type": "string"
+ },
+ "description": "Variable: {key, type: string|number|boolean, default}.",
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["actions"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-list.json
index b5f6b8e2a6f3..027eafa2ddf0 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-list.json
@@ -20,6 +20,11 @@
"description": "The initial index from which to return the results.",
"type": "number"
},
+ "status": {
+ "description": "* `draft` - Draft\n* `active` - Active\n* `archived` - Archived",
+ "enum": ["active", "archived", "draft"],
+ "type": "string"
+ },
"updated_at": {
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-run.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-run.json
new file mode 100644
index 000000000000..6e1f336a725d
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-run.json
@@ -0,0 +1,28 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "current_action_id": {
+ "description": "Start from this action ID instead of the trigger.",
+ "type": "string"
+ },
+ "globals": {
+ "additionalProperties": {},
+ "description": "Test trigger payload, typically {event, person, groups}.",
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "id": {
+ "description": "A UUID string identifying this hog flow.",
+ "type": "string"
+ },
+ "mock_async_functions": {
+ "default": true,
+ "description": "True (default) mocks HTTP/email/SMS. False fires real side effects.",
+ "type": "boolean"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-update.json
new file mode 100644
index 000000000000..d52574e422e3
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/common/workflows-update.json
@@ -0,0 +1,249 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "actions": {
+ "description": "Ordered action nodes. Exactly one type='trigger' required. Typically one type='exit' too.",
+ "items": {
+ "properties": {
+ "config": {
+ "description": "Type-specific config keyed by action type. trigger: {type: event|webhook|manual|batch|schedule|tracking_pixel, filters?}. filters shape: {events: [{id, name, type:'events', properties:[<cond>]}], properties:[<cond>], actions:[...], filter_test_accounts:<bool>}. <cond>: {key, value, operator, type: event|person|group}. function*: {template_id, inputs: {<key>: {value: <str>}}}. Wrap values in {value:...} to enable hog templating ({person.x}, {event.x}); flat strings won't interpolate. delay: {delay_duration: '<number><unit>'} where unit is m|h|d. Fractions OK ('0.5m'=30s; seconds unsupported). Per-unit max m<=60, h<=24, d<=30; values above are SILENTLY CLAMPED. Max 30d. conditional_branch: {conditions: [{filters}, ...]}. Index N matches the 'branch' edge with index:N. wait_until_condition: {condition: {filters}, max_wait_duration: <duration>} (same rules as delay). exit: {reason}."
+ },
+ "created_at": {
+ "description": "Created at (epoch ms). Frontend-managed.",
+ "type": "number"
+ },
+ "description": {
+ "default": "",
+ "description": "Optional description.",
+ "type": "string"
+ },
+ "filters": {
+ "anyOf": [
+ {
+ "properties": {
+ "actions": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "bytecode": {},
+ "bytecode_error": {
+ "type": "string"
+ },
+ "data_warehouse": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "events": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "filter_test_accounts": {
+ "type": "boolean"
+ },
+ "properties": {
+ "items": {
+ "additionalProperties": {},
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "source": {
+ "default": "events",
+ "description": "* `events` - events\n* `person-updates` - person-updates\n* `data-warehouse-table` - data-warehouse-table",
+ "enum": ["events", "person-updates", "data-warehouse-table"],
+ "type": "string"
+ },
+ "transpiled": {}
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Property filters gating this action."
+ },
+ "id": {
+ "description": "Unique node ID within the workflow.",
+ "type": "string"
+ },
+ "name": {
+ "description": "Display name.",
+ "maxLength": 400,
+ "type": "string"
+ },
+ "on_error": {
+ "anyOf": [
+ {
+ "description": "* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch",
+ "enum": ["continue", "abort", "complete", "branch"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "On failure: continue (skip), abort (stop), complete (mark done), branch (follow error edge).\n\n* `continue` - continue\n* `abort` - abort\n* `complete` - complete\n* `branch` - branch"
+ },
+ "output_variable": {
+ "description": "Output variable definition for downstream actions."
+ },
+ "type": {
+ "description": "trigger | function | function_email | function_sms | function_push | delay | conditional_branch | wait_until_condition | wait_until_time_window | random_cohort_branch | exit.",
+ "maxLength": 100,
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "Updated at (epoch ms). Frontend-managed.",
+ "type": "number"
+ }
+ },
+ "required": ["id", "name", "type", "config"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "conversion": {
+ "description": "Conversion goal: {filters: [<cond>, ...], window_minutes}. <cond>: {key, value, operator, type: event|person|group}. Empty filters = any event in window. Required for exit_on_conversion / exit_on_trigger_not_matched_or_conversion. bytecode compiled server-side."
+ },
+ "description": {
+ "description": "Optional description.",
+ "type": "string"
+ },
+ "edges": {
+ "description": "Graph edges: [{from, to, type: 'continue'|'branch', index?}]. 'continue' = fall-through (sequential, or no-match path of conditional_branch). 'branch' requires 'index': matches config.conditions[index] on conditional_branch / wait_until_condition. Every non-exit action needs a reachable next action ('No next action found' otherwise).",
+ "items": {
+ "properties": {
+ "from": {
+ "description": "Source action id.",
+ "type": "string"
+ },
+ "index": {
+ "description": "Required for type='branch'. Index into config.conditions on conditional_branch / wait_until_condition.",
+ "type": "number"
+ },
+ "to": {
+ "description": "Target action id.",
+ "type": "string"
+ },
+ "type": {
+ "description": "continue: fall-through (sequential or the no-match path of conditional_branch). branch: requires 'index' matching config.conditions[index].\n\n* `continue` - continue\n* `branch` - branch",
+ "enum": ["continue", "branch"],
+ "type": "string"
+ }
+ },
+ "required": ["to", "type", "from"],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "exit_condition": {
+ "description": "exit_only_at_end: only at exit node (default). exit_on_conversion: also on conversion (needs 'conversion'; silent no-op otherwise). exit_on_trigger_not_matched: also when trigger filter stops matching. exit_on_trigger_not_matched_or_conversion: both (needs 'conversion').\n\n* `exit_on_conversion` - Conversion\n* `exit_on_trigger_not_matched` - Trigger Not Matched\n* `exit_on_trigger_not_matched_or_conversion` - Trigger Not Matched Or Conversion\n* `exit_only_at_end` - Only At End",
+ "enum": [
+ "exit_on_conversion",
+ "exit_on_trigger_not_matched",
+ "exit_on_trigger_not_matched_or_conversion",
+ "exit_only_at_end"
+ ],
+ "type": "string"
+ },
+ "id": {
+ "description": "A UUID string identifying this hog flow.",
+ "type": "string"
+ },
+ "name": {
+ "anyOf": [
+ {
+ "maxLength": 400,
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Workflow name."
+ },
+ "trigger_masking": {
+ "anyOf": [
+ {
+ "properties": {
+ "bytecode": {
+ "description": "Auto-compiled from hash. Do not set."
+ },
+ "hash": {
+ "description": "HogQL template, e.g. '{person.properties.email}'.",
+ "type": "string"
+ },
+ "threshold": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Min matching events before triggering (k-anonymity)."
+ },
+ "ttl": {
+ "anyOf": [
+ {
+ "maximum": 94608000,
+ "minimum": 60,
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Hash TTL in seconds (60 to ~94M / 3y)."
+ }
+ },
+ "required": ["hash"],
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional dedup: {hash: <HogQL template>, ttl: <seconds, 60-94608000>, threshold?: <int>}. Server compiles bytecode from hash. Omit to disable."
+ },
+ "variables": {
+ "description": "Workflow vars (key, type, default). Total <5KB.",
+ "items": {
+ "additionalProperties": {
+ "type": "string"
+ },
+ "description": "Variable: {key, type: string|number|boolean, default}.",
+ "propertyNames": {
+ "type": "string"
+ },
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-archive.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-archive.json
new file mode 100644
index 000000000000..6c38f5b9f257
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-archive.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A UUID string identifying this hog flow.",
+ "type": "string"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-disable.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-disable.json
new file mode 100644
index 000000000000..6c38f5b9f257
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-disable.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A UUID string identifying this hog flow.",
+ "type": "string"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-enable.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-enable.json
new file mode 100644
index 000000000000..6c38f5b9f257
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/v2/workflows-enable.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A UUID string identifying this hog flow.",
+ "type": "string"
+ }
+ },
+ "required": ["id"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/workflows-run-handler.test.ts b/services/mcp/tests/unit/workflows-run-handler.test.ts
new file mode 100644
index 000000000000..ce4fbca3c94e
--- /dev/null
+++ b/services/mcp/tests/unit/workflows-run-handler.test.ts
@@ -0,0 +1,76 @@
+import { describe, expect, it, vi } from 'vitest'
+
+import { GENERATED_TOOLS } from '@/tools/generated/workflows'
+import type { Context } from '@/tools/types'
+
+interface RequestArgs {
+ method: string
+ path: string
+ body?: Record<string, unknown>
+}
+
+function createMockContext(): { context: Context; request: ReturnType<typeof vi.fn> } {
+ const request = vi.fn().mockResolvedValue({ status: 'success' })
+ const context = {
+ api: {
+ request,
+ getProjectBaseUrl: vi.fn().mockReturnValue('https://us.posthog.com/project/1'),
+ },
+ stateManager: {
+ getProjectId: vi.fn().mockResolvedValue('1'),
+ getOrgID: vi.fn(),
+ getRegion: vi.fn().mockResolvedValue('us'),
+ },
+ env: { POSTHOG_BASE_URL: 'https://us.posthog.com' },
+ sessionManager: {},
+ cache: {},
+ getDistinctId: async () => 'test',
+ } as unknown as Context
+
+ return { context, request }
+}
+
+const runTool = GENERATED_TOOLS['workflows-run']!()
+
+describe('workflows-run handler', () => {
+ it('posts to the invocations endpoint with the workflow id in the path', async () => {
+ const { context, request } = createMockContext()
+
+ await runTool.handler(context, {
+ id: 'wf-123',
+ globals: { event: { event: '$pageview', distinct_id: 'd1' } },
+ mock_async_functions: true,
+ })
+
+ const call = request.mock.calls[0]![0] as RequestArgs
+ expect(call.method).toBe('POST')
+ expect(call.path).toBe('/api/projects/1/hog_flows/wf-123/invocations/')
+ })
+
+ it('forwards globals, mock_async_functions, and current_action_id in the body', async () => {
+ const { context, request } = createMockContext()
+
+ await runTool.handler(context, {
+ id: 'wf-123',
+ globals: { event: { event: '$pageview', distinct_id: 'd1' } },
+ mock_async_functions: false,
+ current_action_id: 'action_42',
+ })
+
+ const call = request.mock.calls[0]![0] as RequestArgs
+ expect(call.body).toEqual({
+ globals: { event: { event: '$pageview', distinct_id: 'd1' } },
+ mock_async_functions: false,
+ current_action_id: 'action_42',
+ })
+ })
+
+ it('omits unset optional fields from the body', async () => {
+ const { context, request } = createMockContext()
+
+ await runTool.handler(context, { id: 'wf-123' })
+
+ const call = request.mock.calls[0]![0] as RequestArgs
+ expect(call.body).toEqual({})
+ })
+})