Skip to content

Connecting PostHog

Read-only, federated access through PostHog's documented private API. Nothing is copied and nothing in PostHog is changed.

What HostPog uses

EndpointScopeWhy
GET /api/users/@me/user:readfind organizations
GET /api/organizations/:id/projects/project:readlist projects + timezone
POST /api/projects/:id/query/query:readbounded HogQL queries (required)
GET /api/projects/:id/event_definitions/event_definition:readevent autocomplete
session_recordings, insights (probe only)session_recording:read, insight:readoptional: 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)

  1. PostHog → Settings → Personal API keys → Create key.
  2. Restrict it to the project and grant read scopes only (list above).
  3. 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 /ph endpoint; 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:smoke

Read-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.