Authentication Method
The PostHog plugin uses API key authentication (api_key) plus your project id (project_id). Which key you store decides what works:
With a personal key, capture still works: the plugin reads the project token from your project, which needs
project:read.
Personal API Key Setup
Step 1: Create the key
- In PostHog, open Settings → Personal API keys (
/settings/user-api-keys) - Click Create personal API key and give it a label such as “Corsair”
- Under Scopes, choose Specific scopes and give Read on the areas you want the agent to see:
query(HogQL, events, web analytics, LLM analytics, error tracking),insight,dashboard,person,cohort,feature_flag,experiment,survey,early_access_feature,session_recording,session_recording_playlist,action,annotation,notebook,alert,event_definition,property_definition,hog_function,batch_export,warehouse_table,logs,project,organization - Give Write only where you want the agent to make changes:
insight,dashboard,feature_flag,cohort,experiment,survey,annotation,action,notebook,person(setting and removing person properties) - Choose which projects the key reaches:
- One project: the key works only with the project id you connect.
- All projects in the organization (or all organizations): one key works everywhere it has access. Every private-API action (not capture) then takes an optional
project_idthat overrides the connected one for that call, andorganizations.list/projects.listshow what is reachable.
- Copy the key (it is shown once)
Step 2: Find your project id
Open any page of your project: the number after/project/ in the URL is the project id (for example https://us.posthog.com/project/12345). It is also under Settings → Project → Project ID. With a key that reaches several projects, this is the default project; projects.list returns the others.
Step 3: Store the credentials
host. For self-hosted PostHog, pass the host (https, or http on localhost):
Project Token (capture only)
If you only send events, a project token is enough: Settings → Project → Project token (starts withphc_). Store it as api_key the same way. Read actions will ask for a personal key.
Webhook Secret
Step 1: Create Webhook Destination
- Go to your PostHog project settings
- Navigate to Data Pipelines → Destinations
- Click New destination
- Select Webhook as the destination type
- Configure:
- Webhook URL: Your webhook endpoint (e.g.,
https://yourapp.com/api/webhook) - Events: Select
event_capturedor all events
- Webhook URL: Your webhook endpoint (e.g.,
- Click Save
- If a webhook secret is provided, copy it and store securely
Required Credentials Summary
For general information about how Corsair handles authentication, see Authentication.