posthog-cli
CLI for the PostHog analytics API. Made with api2cli.dev.
Install
npx api2cli install Melvynx/posthog-cli
This clones the repo, builds the CLI, links it to your PATH, and installs the AgentSkill to your coding agents.
Install AgentSkill only
npx skills add Melvynx/posthog-cli
Usage
posthog-cli auth set "phx_your-personal-api-key"
posthog-cli auth test
posthog-cli --help
Resources
dashboards
| Command | Description |
|---|
posthog-cli dashboards list --json | List all dashboards |
posthog-cli dashboards get <id> --json | Get a dashboard by ID |
posthog-cli dashboards create --name "My Dashboard" --json | Create a dashboard |
posthog-cli dashboards update <id> --name "New Name" --json | Update a dashboard |
posthog-cli dashboards delete <id> --json | Soft-delete a dashboard |
posthog-cli dashboards sharing <id> --json | Get sharing config |
posthog-cli dashboards copy-tile <target-id> --from <src-id> --tile <tile-id> --json | Copy tile |
insights
| Command | Description |
|---|
posthog-cli insights list --json | List all insights |
posthog-cli insights get <id> --json | Get an insight by ID |
posthog-cli insights create --name "My Insight" --json | Create an insight |
posthog-cli insights update <id> --name "Updated" --json | Update an insight |
posthog-cli insights delete <id> --json | Soft-delete an insight |
posthog-cli insights activity <id> --json | Get activity log |
events
| Command | Description |
|---|
posthog-cli events list --json | List recent events |
posthog-cli events list --event "$pageview" --json | Filter by event name |
posthog-cli events get <id> --json | Get a single event |
posthog-cli events values --event "$pageview" --property "$browser" --json | Get property values |
persons
| Command | Description |
|---|
posthog-cli persons list --json | List persons |
posthog-cli persons list --search "user@email.com" --json | Search persons |
posthog-cli persons get <uuid> --json | Get a person |
posthog-cli persons delete <uuid> --json | Delete a person |
posthog-cli persons properties --json | List person property keys |
feature-flags
| Command | Description |
|---|
posthog-cli feature-flags list --json | List all flags |
posthog-cli feature-flags get <id> --json | Get a flag |
posthog-cli feature-flags create --key "feat" --name "Feature" --json | Create a flag |
posthog-cli feature-flags update <id> --active true --json | Enable a flag |
posthog-cli feature-flags delete <id> --json | Delete a flag |
queries
| Command | Description |
|---|
posthog-cli queries run --query "SELECT event, count() FROM events GROUP BY event LIMIT 10" --json | HogQL query |
posthog-cli queries events --event "$pageview" --json | Quick event query |
posthog-cli queries trends --event "$pageview" --interval day --json | Trends query |
posthog-cli queries funnels --events "$pageview,sign_up" --json | Funnel analysis |
annotations
| Command | Description |
|---|
posthog-cli annotations list --json | List annotations |
posthog-cli annotations create --content "Deploy v2" --date "2024-03-15T00:00:00Z" --json | Create |
posthog-cli annotations delete <id> --json | Delete |
actions
| Command | Description |
|---|
posthog-cli actions list --json | List actions |
posthog-cli actions create --name "Sign Up" --json | Create |
posthog-cli actions delete <id> --json | Delete |
cohorts
| Command | Description |
|---|
posthog-cli cohorts list --json | List cohorts |
posthog-cli cohorts create --name "Power Users" --json | Create |
posthog-cli cohorts delete <id> --json | Delete |
exports
| Command | Description |
|---|
posthog-cli exports list --json | List exports |
posthog-cli exports create --dashboard <id> --format-type "image/png" --json | Export dashboard |
Global Flags
All commands support: --json, --format <text|json|csv|yaml>, --verbose, --no-color, --no-header, --env <id>