PostHog

Connect & Ingest data from PostHog

PostHog is an open-source product analytics platform that helps teams understand user behavior. The Sling PostHog connector extracts data from the PostHog API, supporting projects, persons, events, cohorts, feature flags, insights, annotations, actions, session recordings, event definitions, and property definitions.

circle-check

Setup

The following credentials are accepted:

Secrets:

  • api_key (required) -> PostHog Personal API Key

  • project_id (required) -> PostHog Project ID

  • host (optional) -> PostHog host (defaults to us.posthog.com)

Inputs (optional):

  • anchor_date -> Starting date for first sync (defaults to 1 year ago)

Getting Your Credentials

  1. Log in to PostHogarrow-up-right (or your self-hosted instance)

  2. Go to Settings β†’ Personal API Keys

  3. Click Create personal API key

  4. Give it a label (e.g., "Sling Integration")

  5. Under Scopes, select the All access preset (or grant read access to the endpoints you need)

  6. Under Organization & project access, select All access (or choose specific projects)

  7. Click Create key and copy the key (it starts with phx_)

  8. Find your Project ID in Settings β†’ Project (also visible in the URL: https://us.posthog.com/project/<project_id>)

circle-info

Self-Hosted & EU Cloud: If you use PostHog EU Cloud, set host to eu.posthog.com. For self-hosted instances, set host to your custom domain (e.g., posthog.yourcompany.com).

circle-exclamation

Using sling conns

Here are examples of setting a connection named POSTHOG. We must provide the type=api property:

Environment Variable

See here to learn more about the .env.sling file.

Sling Env File YAML

See here to learn more about the sling env.yaml file.

Replication

Here's an example replication configuration to sync PostHog data to a PostgreSQL database:

Endpoints

Endpoint
Description
Incremental
Depends On

projects

Projects (teams) accessible to the user

No

β€”

persons

Persons (users) tracked in the project

No

β€”

events

Events captured in the project

Yes

β€”

cohorts

Cohort definitions

No

β€”

feature_flags

Feature flag definitions

No

β€”

insights

Saved insights (charts, funnels, trends)

No

β€”

annotations

Annotations on charts

Yes

β€”

actions

Actions (custom event groups)

No

β€”

session_recordings

Session recording metadata

Yes

β€”

event_definitions

Event name definitions and metadata

No

β€”

property_definitions

Property definitions and metadata

No

β€”

To discover available endpoints:

Endpoint Details

projects β€” Returns all projects (teams) accessible to the authenticated user. Does not require a project ID scope.

persons β€” Returns all persons (users) tracked in the project, including custom properties and distinct IDs. Uses offset-based pagination.

events β€” Returns events captured in the project. Supports incremental sync via timestamp β€” after the first full extraction, subsequent runs only fetch events newer than the last synced timestamp. Ordered by timestamp descending.

cohorts β€” Returns all cohort definitions in the project, including group properties and membership criteria.

feature_flags β€” Returns all feature flag definitions, including rollout percentages and filter groups.

insights β€” Returns all saved insights (charts, funnels, trends, retention analyses) in the project, including query definitions and dashboard associations.

annotations β€” Returns all annotations in the project. Supports incremental sync via updated_at β€” subsequent runs only fetch annotations created or updated since the last sync.

actions β€” Returns all actions (custom event groups) defined in the project, including their step definitions.

session_recordings β€” Returns session recording metadata (not the actual recordings). Supports incremental sync via start_time β€” subsequent runs only fetch recordings started after the last sync date.

event_definitions β€” Returns all event name definitions and metadata in the project, including tags and verification status.

property_definitions β€” Returns all property definitions in the project, including property types and numerical flags.

Incremental Sync

The events, annotations, and session_recordings endpoints support incremental sync:

  • First run: Fetches all data from the anchor_date (default: 1 year ago) to now

  • Subsequent runs: Only fetches data created or updated since the last sync

To customize the starting date:

Rate Limiting

The PostHog API enforces rate limits of 240 requests/minute for analytics endpoints and 480 requests/minute for CRUD endpoints.

The connector automatically:

  • Uses conservative rate limiting (3 requests/second)

  • Limits concurrency to 2 parallel requests

  • Retries with exponential backoff on 429 (rate limit) responses with up to 5 retry attempts

  • Retries with linear backoff on 5xx server errors with up to 3 retry attempts

If you are facing issues connecting, please reach out to us at [email protected]envelope, on discordarrow-up-right or open a Github Issue herearrow-up-right.

Last updated

Was this helpful?