PostHog CLI Setup PostHog can be configured headlessly with `kosmokrator integrations:configure posthog`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure posthog --set api_token=" $POSTHOG_API_TOKEN " --enable --read allow --write ask --json
kosmokrator integrations:doctor posthog --json
kosmokrator integrations:status --json Credentials
Authentication type: API token api_token. Configure credentials once, then use the same stored profile from
scripts, coding CLIs, Lua code mode, and the MCP gateway.
Call PostHog Headlessly Use the generic call form when another coding CLI or script needs a stable universal interface.
kosmo integrations:call posthog.posthog_capture_event '{
"event": "example_event",
"distinct_id": "example_distinct_id",
"properties": "example_properties",
"timestamp": "example_timestamp"
}' --json Use the provider shortcut form for shorter human-facing commands.
kosmo integrations:posthog posthog_capture_event '{
"event": "example_event",
"distinct_id": "example_distinct_id",
"properties": "example_properties",
"timestamp": "example_timestamp"
}' --json Agent Discovery Commands
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs posthog --json
kosmo integrations:docs posthog.posthog_capture_event --json
kosmo integrations:schema posthog.posthog_capture_event --json
kosmo integrations:search "PostHog" --json
kosmo integrations:list --json All CLI Functions
Every function below can be called headlessly. The generic form is stable across all integrations;
the provider shortcut is shorter but specific to PostHog.
posthog.posthog_capture_event Write write Send (capture) a custom event to PostHog for a specific user. The event will appear in the PostHog events stream and can be used in insights and funnels.
event, distinct_id, properties, timestamp kosmo integrations:call posthog.posthog_capture_event '{"event":"example_event","distinct_id":"example_distinct_id","properties":"example_properties","timestamp":"example_timestamp"}' --json copy kosmo integrations:posthog posthog_capture_event '{"event":"example_event","distinct_id":"example_distinct_id","properties":"example_properties","timestamp":"example_timestamp"}' --json copy
posthog.posthog_list_events Read read List events from PostHog with optional filtering by event name, user, date range, and pagination.
limit, offset, event, distinct_id, person_id, after, before kosmo integrations:call posthog.posthog_list_events '{"limit":1,"offset":1,"event":"example_event","distinct_id":"example_distinct_id","person_id":"example_person_id","after":"example_after","before":"example_before"}' --json copy kosmo integrations:posthog posthog_list_events '{"limit":1,"offset":1,"event":"example_event","distinct_id":"example_distinct_id","person_id":"example_person_id","after":"example_after","before":"example_before"}' --json copy
posthog.posthog_get_event Read read Get details of a specific PostHog event by its unique ID, including all event properties and metadata.
event_id kosmo integrations:call posthog.posthog_get_event '{"event_id":"example_event_id"}' --json copy kosmo integrations:posthog posthog_get_event '{"event_id":"example_event_id"}' --json copy
posthog.posthog_list_persons Read read List persons (users) from PostHog. Optionally search by name, email, or distinct ID to find specific users.
limit, offset, search kosmo integrations:call posthog.posthog_list_persons '{"limit":1,"offset":1,"search":"example_search"}' --json copy kosmo integrations:posthog posthog_list_persons '{"limit":1,"offset":1,"search":"example_search"}' --json copy
posthog.posthog_get_person Read read Get details of a specific PostHog person (user) by their unique ID, including properties and event history metadata.
person_id kosmo integrations:call posthog.posthog_get_person '{"person_id":"example_person_id"}' --json copy kosmo integrations:posthog posthog_get_person '{"person_id":"example_person_id"}' --json copy
posthog.posthog_list_feature_flags Read read List all feature flags in the PostHog project, including their status, rollout percentages, and filter conditions.
limit, offset kosmo integrations:call posthog.posthog_list_feature_flags '{"limit":1,"offset":1}' --json copy kosmo integrations:posthog posthog_list_feature_flags '{"limit":1,"offset":1}' --json copy
posthog.posthog_get_feature_flag Read read Get details of a specific PostHog feature flag by its ID, including rollout configuration and filter conditions.
flag_id kosmo integrations:call posthog.posthog_get_feature_flag '{"flag_id":1}' --json copy kosmo integrations:posthog posthog_get_feature_flag '{"flag_id":1}' --json copy
posthog.posthog_create_feature_flag Write write Create a new feature flag in PostHog with a name, key, and optional rollout configuration.
name, key, active, filters, rollout_percentage kosmo integrations:call posthog.posthog_create_feature_flag '{"name":"example_name","key":"example_key","active":true,"filters":"example_filters","rollout_percentage":1}' --json copy kosmo integrations:posthog posthog_create_feature_flag '{"name":"example_name","key":"example_key","active":true,"filters":"example_filters","rollout_percentage":1}' --json copy
posthog.posthog_update_feature_flag Write write Update an existing PostHog feature flag — change its active state, filters, or rollout percentage.
flag_id, active, filters, rollout_percentage kosmo integrations:call posthog.posthog_update_feature_flag '{"flag_id":1,"active":true,"filters":"example_filters","rollout_percentage":1}' --json copy kosmo integrations:posthog posthog_update_feature_flag '{"flag_id":1,"active":true,"filters":"example_filters","rollout_percentage":1}' --json copy
posthog.posthog_delete_feature_flag Write write Delete a feature flag from PostHog. This action is permanent and cannot be undone.
flag_id kosmo integrations:call posthog.posthog_delete_feature_flag '{"flag_id":1}' --json copy kosmo integrations:posthog posthog_delete_feature_flag '{"flag_id":1}' --json copy
posthog.posthog_list_insights Read read List saved insights in the PostHog project. Optionally filter by insight type (e.g., TRENDS, FUNNELS, RETENTION, PATHS).
limit, offset, type kosmo integrations:call posthog.posthog_list_insights '{"limit":1,"offset":1,"type":"example_type"}' --json copy kosmo integrations:posthog posthog_list_insights '{"limit":1,"offset":1,"type":"example_type"}' --json copy
posthog.posthog_get_insight Read read Get details of a specific PostHog insight by its ID, including its query configuration and cached results.
insight_id kosmo integrations:call posthog.posthog_get_insight '{"insight_id":1}' --json copy kosmo integrations:posthog posthog_get_insight '{"insight_id":1}' --json copy
posthog.posthog_list_dashboards Read read List dashboards in the PostHog project. Dashboards contain collections of insights organized for monitoring.
limit, offset kosmo integrations:call posthog.posthog_list_dashboards '{"limit":1,"offset":1}' --json copy kosmo integrations:posthog posthog_list_dashboards '{"limit":1,"offset":1}' --json copy
posthog.posthog_get_dashboard Read read Get details of a specific PostHog dashboard by its ID, including its layout and contained insights.
dashboard_id kosmo integrations:call posthog.posthog_get_dashboard '{"dashboard_id":1}' --json copy kosmo integrations:posthog posthog_get_dashboard '{"dashboard_id":1}' --json copy
posthog.posthog_list_cohorts Read read List cohorts in the PostHog project. Cohorts are dynamic groups of users defined by behavioral or property conditions.
limit, offset kosmo integrations:call posthog.posthog_list_cohorts '{"limit":1,"offset":1}' --json copy kosmo integrations:posthog posthog_list_cohorts '{"limit":1,"offset":1}' --json copy Function Schemas Use these parameter tables when building CLI payloads without calling integrations:schema first.
Operation Write write
Schema command kosmo integrations:schema posthog.posthog_capture_event --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_list_events --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_get_event --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_list_persons --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_get_person --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_list_feature_flags --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_get_feature_flag --json
Operation Write write
Schema command kosmo integrations:schema posthog.posthog_create_feature_flag --json
Operation Write write
Schema command kosmo integrations:schema posthog.posthog_update_feature_flag --json
Operation Write write
Schema command kosmo integrations:schema posthog.posthog_delete_feature_flag --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_list_insights --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_get_insight --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_list_dashboards --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_get_dashboard --json
Operation Read read
Schema command kosmo integrations:schema posthog.posthog_list_cohorts --json Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults
with integrations:configure. Add --force only for trusted automation that should bypass that policy.