Connecting PostHog
Read-only, federated access through PostHog's documented private API. Nothing is copied and nothing in PostHog is changed.
What HostPog uses
| Endpoint | Scope | Why |
|---|---|---|
GET /api/users/@me/ | user:read | find organizations |
GET /api/organizations/:id/projects/ | project:read | list projects + timezone |
POST /api/projects/:id/query/ | query:read | bounded HogQL queries (required) |
GET /api/projects/:id/event_definitions/ | event_definition:read | event autocomplete |
session_recordings, insights (probe only) | session_recording:read, insight:read | optional: recording links, saved insights |
Hosts: https://us.posthog.com, https://eu.posthog.com, or an operator-approved self-hosted origin. Public capture hosts are never used.
Personal API key (default)
- PostHog → Settings → Personal API keys → Create key.
- Restrict it to the project and grant read scopes only (list above).
- Paste it into HostPog. It is validated, scope-probed, encrypted with AES-256-GCM and never displayed again.
OAuth
PostHog registers OAuth clients with a Client ID Metadata Document: the client ID is an HTTPS URL on your domain. HostPog serves it at /oauth/posthog-client.json and uses authorization code + PKCE (S256), single-use state, exact redirect URIs, token refresh and revocation on disconnect. It only works when HostPog is reachable over public HTTPS and HOSTPOG_POSTHOG_OAUTH_ENABLED=true. Unverified apps show an "unverified application" notice in PostHog until verification.
Limits and freshness
- PostHog documents 2,400 query requests/hour and 240/minute per key, a 10-second execution limit and 3 concurrent queries per project. HostPog budgets itself to 80% of that by default and honours
Retry-After. - Results are cached per tenant, source, credential and query fingerprint for 60 s; PostHog's own cache state is shown as "cached / data as of".
- HostPog never pages the query endpoint to dump events. Event lists use keyset pagination and small limits.
What is not available in connect mode
- Embedded session replay. HostPog shows sessions and links to the recording in PostHog, where PostHog checks access.
- Your existing PostHog feature flags and surveys stay in PostHog. HostPog's own flags, experiments and surveys are served to posthog-js once the SDK points at HostPog's
/phendpoint; while PostHog still runs in parallel, both sets are merged in one response, HostPog's winning on a key clash. - Error tracking: not built yet.
Verify against your own project
POSTHOG_SMOKE_API_KEY=phx_... POSTHOG_SMOKE_REGION=us pnpm posthog:smokeRead-only. Prints discovered projects, which scopes work and the result counts of one summary, trend, funnel, events, persons and web query.
Migrating off PostHog
Open Migrate from PostHog in the app: import a batch export, check the counts match, then switch your SDK. Your PostHog capture keeps running until you cut over.