Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Apps

Query PostHog with HogQL

Runs one HogQL SELECT (PostHog's SQL, over tables like events and persons) in the workspace's PostHog and returns at most 100 rows. HogQL can only read. Prefer aggregates (count, uniq, group by) over raw rows. Needs PostHog connected.

get/api/v1/apps/posthog/query

Authorization

HeaderAuthorization: Bearer <API key>
Or the headerX-API-Key: <API key>
API keyMake one in Troopy under Settings > API keys. It acts as you, in its workspace.
Scopesapps:read

Other ways to call it

CLItroopy posthog query
MCP tooltroopy_posthog_query
Rate limit30 calls in 60 seconds, for each key

Query parameters

q*string

A HogQL query, like: select event, count() from events where timestamp > now() - interval 7 day group by event

At least 1 characters · At most 2000 characters

Response

200 · application/json
data*object
3 properties
columns*array<string>
rows*array<array<any>>

At most 100

truncated*boolean

More rows matched than came back: narrow the query or aggregate

Errors

400 invalid_inputFix the field named in detail. Each operation's schema is in /api/v1/openapi.json.
401 unauthorizedSend an API key as `Authorization: Bearer tr_live_...`. Create one in Troopy under Settings.
403 forbiddenThe key lacks a scope this operation needs, or its owner lacks the role. detail says which; create a key with the scope, or ask an organization owner or admin.
429 rate_limitedWait the number of seconds in Retry-After, then retry.