Skip to main content
Product analytics platform API for querying events, managing feature flags, running experiments, and accessing session replays. Best for workflows that need to read analytics data, toggle feature flags programmatically, or automate experiment management. Unlike Mixpanel or Amplitude, PostHog is open-source with a self-hostable option. 9 example endpoints available through Lava’s AI Gateway. See the PostHog API docs for full documentation.
This provider requires your own credentials — connect your API key or OAuth account before use.
This is a catch-all provider — any valid URL under https://us.posthog.com is supported. Any PostHog API endpoint. Construct URL as https://us.posthog.com/api/{path}. See https://posthog.com/docs/api for full reference. The endpoints below are curated examples.

Endpoints

POST https://us.posthog.com/api/environments/{env_id}/query/ — Free
const data = await lava.gateway('https://us.posthog.com/api/environments/{env_id}/query/', {
  body: {
"query": {
  "kind": "HogQLQuery",
  "query": "SELECT count() FROM events"
}
},
});

List feature flags

GET https://us.posthog.com/api/projects/{project_id}/feature_flags/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/feature_flags/', { method: 'GET' });

Query events

GET https://us.posthog.com/api/projects/{project_id}/events/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/events/', { method: 'GET' });

List persons (users)

GET https://us.posthog.com/api/projects/{project_id}/persons/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/persons/', { method: 'GET' });

List saved insights

GET https://us.posthog.com/api/projects/{project_id}/insights/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/insights/', { method: 'GET' });

List dashboards

GET https://us.posthog.com/api/projects/{project_id}/dashboards/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/dashboards/', { method: 'GET' });

Replace a feature flag

PUT https://us.posthog.com/api/projects/{project_id}/feature_flags/{flag_id}/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/feature_flags/{flag_id}/', { method: 'PUT', body: {"name":"my-flag","key":"my-flag","active":true} });

Update a feature flag

PATCH https://us.posthog.com/api/projects/{project_id}/feature_flags/{flag_id}/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/feature_flags/{flag_id}/', { method: 'PATCH', body: {"active":true} });

Delete an annotation

DELETE https://us.posthog.com/api/projects/{project_id}/annotations/{annotation_id}/ — Free
const data = await lava.gateway('https://us.posthog.com/api/projects/{project_id}/annotations/{annotation_id}/', { method: 'DELETE' });

Next Steps

All Providers

Browse all supported AI providers

Forward Proxy

Learn how to construct proxy URLs and authenticate requests