PostHog Integration
Connect PostHog to bring your PostHog spend, usage and configuration into Cloud ex Machina.
| Data | PostHog API | Key scope |
|---|---|---|
| Spend and usage per product, project and day | Billing (/api/billing/spend, /api/billing/usage) | billing:read |
| Projects | Projects | project:read |
| Event volumes per event and per day | Query (HogQL) | query:read |
| Event definitions | Event definitions | event_definition:read |
| Session recordings | Session recordings | session_recording:read |
| Feature flags | Feature flags | feature_flag:read |
Permissions summary
| Setting | Value |
|---|---|
| Key type | Personal API key (phx_…) |
| Organization & project access | All access or Organizations |
| Scopes | billing:read, project:read, query:read, event_definition:read, session_recording:read, feature_flag:read |
| Key owner role | Owner 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
- Sign in to PostHog.
- Look at the URL in your browser.
| URL | Subdomain to select |
|---|---|
https://us.posthog.com | us |
https://eu.posthog.com | eu |
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.
- In PostHog, open Settings > User > Personal API keys.
- Click + Create a personal API key and name it
Cloud ex Machina. - Under Organization & project access, select All access or Organizations. Do not select a project.
- Give the key the scopes
billing:read,project:read,query:read,event_definition:read,session_recording:readandfeature_flag:read. Do not give it other scopes. - 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
- In the sidebar, click Integrations.
- Find PostHog and click Sign in. If the integration already has a connection, the button is Add connection.
- Fill in:
- Subdomain: the subdomain from Step 1.
- API Key: the key from Step 2.
- Submit the form. Cloud ex Machina saves the connection.
Remove a connection
- Click the connection row under the PostHog card.
- Click Disconnect.
- Delete the personal API key in PostHog.
Next Steps
- See all available integrations in the Integrations Overview.