> Documentation index: https://metorial.com/llms.txt. Every page is available as Markdown by adding .md to its URL.

# Set up PostHog in Metorial for Claude, ChatGPT and Cursor
URL: https://metorial.com/docs/integrations/posthog
Last updated: 2026-11-24

Share PostHog with your team in Claude, ChatGPT and Cursor through Metorial: OAuth or personal API key sign-in, 56 tools (30 read-only).

---

To give your team PostHog in Claude, ChatGPT, Cursor and other AI clients, an admin shares the PostHog integration in a Metorial portal, and each person signs in to PostHog with their own account. Agents can capture and analyze product usage events, manage feature flags, run A/B test experiments, and create user surveys. The integration has 56 tools, 30 read-only, 17 write and 9 destructive, plus 3 triggers.

**What you will learn**

- How an admin shares PostHog in a portal and how each person connects
- The 31 OAuth scopes PostHog can request, and what each one allows
- How to keep the 30 read-only tools and reject the other 26

**Before you start**

- A [portal](https://metorial.com/docs/platform/workforce/portals) with at least one access group
- An account with PostHog for each person who connects
- For the CLI steps: the [Metorial CLI](https://metorial.com/docs/platform/cli), signed in to your portal

## Sign-in methods

| Method | Type | What a person provides |
| --- | --- | --- |
| **OAuth 2.0** (default) | OAuth | Signs in to PostHog after entering `instanceUrl` and `projectToken` |
| **Personal API Key** | API token | `apiKey` and `projectToken` |

Also available: **OAuth 2.0 (Client Metadata URL)**.

The portal and `metorial setup` use **OAuth 2.0** unless someone picks another method.

### OAuth 2.0

Before the sign-in, setup asks for:

- `instanceUrl` (optional): PostHog instance URL (leave empty for US cloud)
- `projectToken` (optional): Project API key/token for event capture and flag evaluation

People sign in to PostHog and approve the scopes you allow. The integration can request:

| Scope | Name | What it allows |
| --- | --- | --- |
| `openid` | OpenID | OpenID Connect authentication |
| `profile` | Profile | Access user profile information |
| `action:read` | Read Actions | Read actions |
| `action:write` | Write Actions | Create and update actions |
| `activity_log:read` | Read Activity Log | Read activity log entries |
| `annotation:read` | Read Annotations | Read annotations |
| `annotation:write` | Write Annotations | Create and update annotations |
| `cohort:read` | Read Cohorts | Read cohorts |
| `cohort:write` | Write Cohorts | Create and update cohorts |
| `dashboard:read` | Read Dashboards | Read dashboards |
| `dashboard:write` | Write Dashboards | Create and update dashboards |
| `experiment:read` | Read Experiments | Read experiments (A/B tests) |
| `experiment:write` | Write Experiments | Create and update experiments |
| `feature_flag:read` | Read Feature Flags | Read feature flags |
| `feature_flag:write` | Write Feature Flags | Create and update feature flags |
| `insight:read` | Read Insights | Read insights |
| `insight:write` | Write Insights | Create and update insights |
| `group:read` | Read Groups | Read groups and group types |
| `group:write` | Write Groups | Create and update group properties |
| `person:read` | Read Persons | Read person profiles |
| `person:write` | Write Persons | Update and delete person profiles |
| `organization:read` | Read Organizations | Read organizations and discover projects |
| `user:read` | Read Users | Read the current user profile |
| `project:read` | Read Projects | Read project settings |
| `project:write` | Write Projects | Update project settings |
| `session_recording:read` | Read Session Recordings | Read session recording metadata |
| `survey:read` | Read Surveys | Read surveys |
| `survey:write` | Write Surveys | Create and update surveys |
| `event_definition:read` | Read Event Definitions | Read event definitions |
| `property_definition:read` | Read Property Definitions | Read property definitions |
| `query:read` | Read Query | Run HogQL queries |

### Personal API Key

To connect, a person enters these values:

- `apiKey`: Personal API key (starts with phx_)
- `projectToken` (optional): Project API key/token for event capture and flag evaluation

### Setup settings

Whichever method you pick, setup also asks for:

- `region` (optional): PostHog cloud region or self-hosted One of "us", "eu", "self-hosted".
- `instanceUrl` (optional): Custom instance URL for self-hosted PostHog (e.g. https://posthog.example.com). Required when region is self-hosted.
- `projectId` (optional): PostHog project ID. Required for most private API endpoints.

## Use your own PostHog OAuth app

With your own OAuth app, people see your company's name on the PostHog consent screen, and the client ID and secret belong to you.

1. **Start the credentials in Metorial**

   In the dashboard, select **Settings**, then **Organization Settings**. Under **Integrations and MCP**, select **Provider Auth**, then **Create Auth Credentials**. Choose PostHog and copy the **Redirect URI**.

2. **Register the app with PostHog**

   Create an OAuth app or client in PostHog and add the redirect URI from Metorial as its redirect or callback URL.

3. **Finish in Metorial**

   Copy the app's client ID and client secret. Back in Metorial, enter a **Name**, the **Client ID** and the **Client Secret**, review **Scopes**, and select **Create**. Then pick these credentials for the PostHog integration.

## Admin: share PostHog in a portal

### In the dashboard

1. **Open Shared Resources**

   Open **Workforce**, choose the portal, and select **Shared Resources** under **Access**.

2. **Share a new integration**

   Select **Share a Resource**, then **New Integration**, and choose PostHog. Under **Auth Method**, keep **OAuth 2.0** or pick another. For how members connect, choose **Each person connects**, so everyone signs in to PostHog as themselves.

3. **Limit the tools**

   Under **Tool Filters**, set the write and destructive groups to **Reject** if agents should only read from PostHog.

4. **Choose who gets it**

   Add the access groups that should see PostHog. When a person asks for access from the portal, the request appears under **Access Requests**.

### With the CLI

The CLI cannot create the per-user PostHog integration. Once it exists, check which groups have it:

```bash
metorial-admin portals access list <portal-id> --type provider_template --search posthog
```

## Employee: connect PostHog

### In the portal

1. **Open PostHog in the catalog**

   Sign in to your portal and open PostHog. The status reads **Available**.

2. **Authenticate**

   Under **Quick setup**, select **Authenticate**. A PostHog sign-in tab opens. Sign in and approve the permissions listed.

3. **Confirm**

   The status changes to **Configured**. If it later reads **Needs reconnect**, select **Reconnect** and sign in again.

### With the CLI

```bash
metorial catalog search posthog
metorial setup <catalog-item-id>
```

`catalog search` prints the catalog item ID. `metorial setup` uses **OAuth 2.0**. To connect with **Personal API Key** instead, find its ID with `metorial catalog get <catalog-item-id>` and add `--auth-method <auth-method-id>`.

### Add it to your AI client

`metorial install` adds your PostHog connection to a local MCP client such as Claude Code, Cursor or Codex. `metorial list` prints the integration ID and `metorial client list` the client identifiers.

```bash
metorial list posthog
metorial client list
metorial install <client-identifier> <integration-id>
```

For a client that takes a server URL, such as ChatGPT, `metorial install custom <integration-id>` creates an installation token and shows the endpoint details.

## Make it read-only

Open the integration's **Tool Filters** and set the write and destructive groups to **Reject**. Agents keep the 30 read-only tools, such as `run_query` and `find_group`, and lose the 17 write tools, such as `create_group` or `capture_event`, and the 9 destructive tools, such as `delete_action` or `delete_cohort`.

Employees see the result on the integration's page in the portal under **Tool access**. For the full walkthrough, see [Tool permissions](https://metorial.com/docs/platform/guides/tool-permissions).

## Check it worked

```bash
metorial list posthog
metorial tools <integration-id>
metorial call <integration-id> get_current_user -d '{}'
```

`metorial tools` lists the 56 tools, minus any you rejected. `get_current_user` takes no input. It retrieves the current PostHog user, current organization, and current team/project context.

To see every input a tool takes, run `metorial schema <integration-id> <tool-key>`.

## Tools

### Read-only tools (30)

- `list_session_recordings`: List session recording metadata.
- `list_insights`: List analytics insights (trends, funnels, retention, paths, stickiness, lifecycle).
- `list_property_definitions`: List all property definitions in the project.
- `list_cohorts`: List all cohorts in the project.
- `get_feature_flag`: Retrieve detailed information about a specific feature flag by its ID. Needs `flagId`.
- `get_experiment`: Retrieve detailed information about a specific A/B test experiment including its configuration, metrics, and results. Needs `experimentId`.
- `get_insight`: Retrieve detailed information and results for a specific insight by its ID. Needs `insightId`.
- `list_projects`: List projects accessible with the current credentials.
- `list_event_definitions`: List all event definitions in the project.
- `list_persons`: Search and list person profiles in PostHog.
- `get_dashboard`: Retrieve detailed information about a specific dashboard by its ID, including its tiles and configuration. Needs `dashboardId`.
- `list_feature_flags`: List all feature flags in the project.
- `get_session_recording`: Retrieve metadata about a specific session recording by its ID. Needs `recordingId`.
- `list_annotations`: List annotations on charts/dashboards.
- `evaluate_feature_flags`: Evaluate all feature flags for a specific user (distinct ID). Needs `distinctId`.
- `get_person`: Retrieve detailed information about a specific person by their PostHog person ID. Needs `personId`.
- `get_survey`: Retrieve detailed information about a specific survey by its ID, including questions, targeting, and status. Needs `surveyId`.
- `list_experiments`: List A/B test experiments in the project.
- `get_cohort`: Retrieve detailed information about a specific cohort by its ID. Needs `cohortId`.
- `list_surveys`: List all surveys in the project with their configuration, questions, and status.
- `list_dashboards`: List all dashboards in the project.
- `run_query`: Execute an ad-hoc HogQL query against your PostHog data. Needs `query`.
- `get_annotation`: Retrieve a specific PostHog annotation by ID. Needs `annotationId`.
- `get_action`: Retrieve a specific PostHog action by ID, including its step rules. Needs `actionId`.
- `list_actions`: List PostHog actions.
- `list_group_types`: List configured PostHog group types.
- `list_groups`: List groups for a specific PostHog group type. Needs `groupTypeIndex`.
- `get_current_user`: Retrieve the current PostHog user, current organization, and current team/project context.
- `list_organizations`: List PostHog organizations accessible with the current credentials.
- `find_group`: Find a specific PostHog group by group type index and group key. Needs `groupTypeIndex` and `groupKey`.

### Write tools (17)

- `create_experiment`: Create a new A/B test experiment. Needs `name`.
- `capture_event`: Send one or more events to PostHog. Needs `events`.
- `create_dashboard`: Create a new dashboard for organizing insights and analytics visualizations. Needs `name`.
- `create_cohort`: Create a new cohort. Needs `name`.
- `update_dashboard`: Update an existing dashboard's name, description, pinned status, or tags. Needs `dashboardId`.
- `update_experiment`: Update an existing A/B test experiment's name, description, dates, or configuration. Needs `experimentId`.
- `update_survey`: Update an existing survey's name, description, questions, targeting, or dates. Needs `surveyId`.
- `create_survey`: Create a new survey with questions and optional targeting. Needs `name`.
- `create_annotation`: Create a new annotation to mark a significant event or deployment on PostHog charts and dashboards. Needs `content` and `dateMarker`.
- `update_feature_flag`: Update an existing feature flag's name, active status, rollout percentage, or targeting configuration. Needs `flagId`.
- `create_feature_flag`: Create a new feature flag. Needs `key`.
- `update_group_property`: Set or update properties for a PostHog group. Needs `groupTypeIndex`, `groupKey` and `groupProperties`.
- `create_action`: Create a PostHog action from event, selector, URL, or property matching steps. Needs `name`.
- `create_group`: Create or update a PostHog group for a configured group type. Needs `groupTypeIndex` and `groupKey`.
- `update_annotation`: Update an annotation's content, date marker, or scope. Needs `annotationId`.
- `update_cohort`: Update an existing cohort's name, description, static state, or filter groups. Needs `cohortId`.
- `update_action`: Update a PostHog action's metadata, tags, deletion state, or step rules. Needs `actionId`.

### Destructive tools (9)

- `delete_feature_flag`: Permanently delete a feature flag. Needs `flagId`.
- `delete_survey`: Permanently delete a survey. Needs `surveyId`.
- `delete_annotation`: Delete an annotation from charts/dashboards. Needs `annotationId`.
- `delete_dashboard`: Permanently delete a dashboard. Needs `dashboardId`.
- `delete_person`: Permanently delete a person profile from PostHog. Needs `personId`.
- `delete_cohort`: Permanently delete a cohort from PostHog. Needs `cohortId`.
- `delete_action`: Delete a PostHog action. Needs `actionId`.
- `delete_experiment`: Permanently delete an experiment from PostHog. Needs `experimentId`.
- `delete_group_property`: Delete one or more properties from a PostHog group. Needs `groupTypeIndex` and `groupKey`.

## Triggers

PostHog has 3 triggers, which fire on events in PostHog:

- `feature_flag_changes`: Triggers when feature flags are created or updated.
- `inbound_webhook`
- `new_events`: Triggers when new events are captured in PostHog.

## Next steps

- [Claude Code](https://metorial.com/docs/platform/clients/claude-code), [Cursor](https://metorial.com/docs/platform/clients/cursor), [Codex](https://metorial.com/docs/platform/clients/codex) and [ChatGPT](https://metorial.com/docs/platform/clients/chatgpt): connect each client to your portal and use PostHog there
- [Create custom OAuth credentials](https://metorial.com/docs/platform/integrations/create-custom-oauth-credentials): the Provider Auth screens in more detail
- [Tool permissions](https://metorial.com/docs/platform/guides/tool-permissions): tool filters and what employees see
- [PostHog on metorial.com](https://metorial.com/integrations/posthog): the integration overview