> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sazabi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostHog

> Connect your PostHog account so Sazabi can install and manage a webhook destination for the projects you select.

[All PostHog integration capabilities](https://docs.sazabi.com/catalogs/integrations/posthog)

## About

PostHog's Data Pipeline forwards each matching event to Sazabi as a JSON payload, and Sazabi stores it as a log. Connecting your PostHog account lets Sazabi install and maintain an HTTP Webhook destination (a PostHog "hog function") for each project you select.

PostHog also has a **Send to an endpoint** path where you configure the webhook destination yourself. See [PostHog endpoint page](https://docs.sazabi.com/catalogs/log-sources/send-to-an-endpoint/posthog.md) for that setup.

> [!WARNING]
>
> PostHog CDP / Data Pipeline destinations are a paid feature. Confirm your PostHog plan includes Data Pipeline access before connecting.

## Prerequisites

* A PostHog organization with Data Pipeline access.
* A PostHog personal API key with these scopes:
  * `project:read` — list your projects
  * `organization:read` — show your organization
  * `hog_function:write` — install the webhook destination
* Your PostHog region: **US** (`us.posthog.com`) or **EU** (`eu.posthog.com`).

## Set up in the dashboard

**Step 1**

### Create a personal API key

In PostHog, go to **Settings > Personal API keys** ([US](https://us.posthog.com/settings/user-api-keys) or [EU](https://eu.posthog.com/settings/user-api-keys)) and create a key with the three scopes listed above (`project:read`, `organization:read`, `hog_function:write`). The key starts with `phx_`.

**Step 2**

### Connect in Sazabi

Go to [**Settings > Log streams**](https://app.sazabi.com/settings/log-source-providers), click **Add source**, and select **PostHog**. Enter your personal API key and click **Connect**. Sazabi validates the key and identifies your PostHog region and organization automatically.

**Step 3**

### Add log streams

After the connection is confirmed, click **Add log stream** to open the project picker. Select the PostHog projects you want to forward. For each project, Sazabi installs an HTTP Webhook destination that posts events to the Sazabi intake URL.

## Set up with the CLI

You can also connect the PostHog log source with the [Sazabi CLI](https://docs.sazabi.com/reference/cli.md) (installed and authenticated — see [CLI reference](https://docs.sazabi.com/reference/cli/log-sources.md)).

Create a native connection by passing your personal API key and PostHog region as metadata:

```bash theme={"system"}
sazabi log-sources create posthog --mode native \
  --metadata '{"posthogPersonalApiKey":"'"$POSTHOG_PERSONAL_API_KEY"'","posthogApiRegion":"us"}'
```

Set `posthogApiRegion` to `us` or `eu` to match your PostHog Cloud region. Use a key with the same scopes as the dashboard flow (`project:read`, `organization:read`, `hog_function:write`). Sazabi validates it against the PostHog API and creates the log source; note the log source ID it prints.

Add a log stream — one per PostHog project — with `sazabi log-streams create`, passing the PostHog project ID and name in `--config`:

```bash theme={"system"}
sazabi log-streams create --log-source-id <log-source-id> \
  --config '{"posthogProjectId":"<your PostHog project ID>","posthogProjectName":"<project name>"}'
```

Run `sazabi log-sources list` to confirm the source and its streams.

## Verify

In a connected PostHog project, send a test event — capture an event from a client SDK, run a backend event capture, or use PostHog's built-in test event feature in the Data Pipeline destination settings.

Open the [Intake page](https://docs.sazabi.com/guides/instrument/intake.md) in the Sazabi dashboard and confirm that records attributed to the **PostHog** source appear. Events typically arrive within one to two minutes.

## Troubleshooting

**Token validation fails** — Confirm the key starts with `phx_` and has all three required scopes: `project:read`, `organization:read`, and `hog_function:write`. A key missing `hog_function:write` will pass the project listing step but fail when Sazabi tries to install the destination.

**No projects appear in the picker** — Verify the key has `project:read` scope. If the organization has no projects, create one in PostHog first.

**Events stop arriving** — The hog function (webhook destination) may have been disabled or deleted in PostHog, or the personal API key may have been revoked. Remove and re-add the log stream from [**Settings > Log streams**](https://app.sazabi.com/settings/log-source-providers) in Sazabi to reinstall the destination.

**Data Pipeline access error** — Confirm your PostHog plan includes Data Pipeline / CDP destination support. Free plans may not have access to this feature.

## Further reading

> [card] [Intake](https://docs.sazabi.com/guides/instrument/intake.md)
>
> See per-source ingestion volume and health in the Intake page.

> [card] [PostHog (send to an endpoint)](https://docs.sazabi.com/catalogs/log-sources/send-to-an-endpoint/posthog.md)
>
> Configure a PostHog HTTP Webhook destination yourself.

> [card] [Log sources](https://docs.sazabi.com/catalogs/log-sources.md)
>
> Browse the full log source catalog.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.