Overview
OneCLI connects AI agents to PostHog with a personal API key. Agents can run HogQL queries, read insights, dashboards, experiments, and session recordings, and create or update feature flags. The gateway injects the key into requests tous.posthog.com or eu.posthog.com, so your agent never sees it. Both US and EU Cloud are supported.
Setup
1
Create a personal API key
In PostHog, go to Settings > User > Personal API keys and create a key. Grant only the scopes your agents need, and include User: read so OneCLI can show which account is connected. Keys start with
phx_. See Personal API keys.2
Connect in OneCLI
Open Connections > PostHog and paste your key. OneCLI detects whether it belongs to US or EU Cloud. Under Advanced you can add an optional connection label to tell multiple PostHog accounts apart.
What agents can do
What a connection can actually reach follows the API key: scopes you left out when creating the key return permission errors, regardless of what OneCLI allows.
Quick example
Replace12345 with your project ID (shown in PostHog under Settings > Project). No auth header is needed, the gateway adds it:
eu.posthog.com instead.
Disconnecting
- In OneCLI, open Connections > PostHog and remove the connection.
- Then delete the key in PostHog under Settings > User > Personal API keys.