Skip to main content
This guide walks you through obtaining all required credentials for the PostHog plugin.

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

  1. In PostHog, open Settings → Personal API keys (/settings/user-api-keys)
  2. Click Create personal API key and give it a label such as “Corsair”
  3. 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
  4. 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)
  5. 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_id that overrides the connected one for that call, and organizations.list / projects.list show what is reachable.
  6. Copy the key (it is shown once)
A call whose scope is missing returns 403; the rest keep working.

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

Verify it was saved:
With a personal key, US and EU cloud are detected on the first call; a project token uses the US host unless you set 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 with phc_). Store it as api_key the same way. Read actions will ask for a personal key.

Webhook Secret

Step 1: Create Webhook Destination

  1. Go to your PostHog project settings
  2. Navigate to Data Pipelines → Destinations
  3. Click New destination
  4. Select Webhook as the destination type
  5. Configure:
    • Webhook URL: Your webhook endpoint (e.g., https://yourapp.com/api/webhook)
    • Events: Select event_captured or all events
  6. Click Save
  7. If a webhook secret is provided, copy it and store securely
Storing Credentials: Store the webhook secret with the CLI:

Required Credentials Summary

For general information about how Corsair handles authentication, see Authentication.