Skip to content
Software capabilities

PostHog capability

Query PostHog event data

Send a HogQL query to the Query API when an application needs the results. Use the PostHog SQL editor or the execute-sql MCP tool for an interactive query.

Documentation reviewed

Ways to do it

API

POST /api/projects/{project_id}/query/ with HogQLQuery

Send a read query and use the returned columns and rows in your application.

Requirements
PostHog project ID, the correct regional app host, and a personal API key with query:read permission.
Limitations
Bound large queries with a time filter and an explicit row limit. Synchronous responses may be too slow for large scans.

Example

curl --fail -H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":{"kind":"HogQLQuery","query":"SELECT event, count() AS total FROM events WHERE timestamp >= now() - INTERVAL 1 DAY GROUP BY event ORDER BY total DESC LIMIT 10"}}' \
  "$POSTHOG_HOST/api/projects/$PROJECT_ID/query/"
Read source: PostHog Query API

MCP

execute-sql

Run a SQL query against PostHog from an MCP client.

Requirements
An authenticated PostHog MCP client with access to the intended project and the execute-sql tool available.
Limitations
The query runs in the selected project. Confirm the project before interpreting the result.
Read source: PostHog MCP tools

Interface

PostHog SQL editor

Write and run a SQL query in PostHog and inspect the results. Save it as an insight if you need to revisit it.

Requirements
Access to the PostHog project and the SQL editor.
Limitations
Saved SQL insights default to a row limit of 100. Set a limit in the query when you need a different result size.
Read source: PostHog SQL editor