Skip to main content

PostHog Integration

Connect PostHog to bring your PostHog spend, usage and configuration into Cloud ex Machina.

DataPostHog APIKey scope
Spend and usage per product, project and dayBilling (/api/billing/spend, /api/billing/usage)billing:read
ProjectsProjectsproject:read
Event volumes per event and per dayQuery (HogQL)query:read
Event definitionsEvent definitionsevent_definition:read
Session recordingsSession recordingssession_recording:read
Feature flagsFeature flagsfeature_flag:read

Permissions summary​

SettingValue
Key typePersonal API key (phx_…)
Organization & project accessAll access or Organizations
Scopesbilling:read, project:read, query:read, event_definition:read, session_recording:read, feature_flag:read
Key owner roleOwner of the PostHog organization, or Admin if billing access is not for owners only

PostHog rejects billing calls from a key with project access only.


Prerequisites​

  • Cloud ex Machina Admin access.
  • An Owner of the PostHog organization. An Admin can also read billing, unless the organization gives billing access to owners only.
  • If the key owner is a member of more than one PostHog organization, open the organization to connect before you create the key.

Step 1: Find your PostHog region​

  1. Sign in to PostHog.
  2. Look at the URL in your browser.
URLSubdomain to select
https://us.posthog.comus
https://eu.posthog.comeu

Do not select us.i or eu.i. These hosts receive events only.

Step 2: Create a personal API key​

Key type

Use a personal API key. It starts with phx_. A project token starts with phc_ and does not work for this connection.

  1. In PostHog, open Settings > User > Personal API keys.
  2. Click + Create a personal API key and name it Cloud ex Machina.
  3. Under Organization & project access, select All access or Organizations. Do not select a project.
  4. Give the key the scopes billing:read, project:read, query:read, event_definition:read, session_recording:read and feature_flag:read. Do not give it other scopes.
  5. Click Save key and copy the key. PostHog shows the key only once.

If the key owner leaves the PostHog organization, the key stops working.

Step 3: Add the connection in Cloud ex Machina​

  1. In the sidebar, click Integrations.
  2. Find PostHog and click Sign in. If the integration already has a connection, the button is Add connection.
  3. Fill in:
    • Subdomain: the subdomain from Step 1.
    • API Key: the key from Step 2.
  4. Submit the form. Cloud ex Machina saves the connection.

Remove a connection​

  1. Click the connection row under the PostHog card.
  2. Click Disconnect.
  3. Delete the personal API key in PostHog.

Next Steps​