> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webrouter.net/llms.txt
> Use this file to discover all available pages before exploring further.

# PostHog

> Product analytics from a PostHog project: SQL (HogQL) queries over events and persons, saved insights and dashboards, persons, events and feature flags.

![](https://mintcdn.com/webrouter/T_A5Quwg50s_JK2y/logo/data-apis/posthog.webp?fit=max\&auto=format\&n=T_A5Quwg50s_JK2y\&q=85\&s=fc8077b791a6e14d29f3f90d51782186)

[Web Catalog · Analytics](https://docs.webrouter.net/data-apis.md?category=analytics)

Needs&#x20;

`POSTHOG_PERSONAL_API_KEY`

Endpoints

9

Auth

Key in header

[Vendor docs](https://posthog.com/docs/api)

&#x20;·&#x20;

[Pricing](https://posthog.com/pricing)

## Setup

| Variable | | What it is |
| - | - | - |
| `POSTHOG_PERSONAL_API_KEY` | required | a PostHog personal API key (Settings > Personal API keys) with the read scopes needed; not the project token |
| `POSTHOG_REGION` | optional | PostHog Cloud region: us (us.posthog.com) or eu (eu.posthog.com). A key only works in its own region. Default `us`. One of `us`, `eu`. |

Put them in your environment or `.env`; [Data APIs](https://docs.webrouter.net/vendors.md) covers the other ways.

## Notes

* Every project endpoint needs the numeric project\_id in the path; it is in the project's settings and app URL.
* The query endpoint is the general way to read data: SQL over events, persons, sessions. Without your own LIMIT it returns 100 rows; with one, up to 50,000. It is not an export path.
* Rate limits per key: query 240/min and 2,400/hour with 3 concurrent queries and a 10 s execution cap per project; analytics endpoints (insights, persons) 240/min and 1,200/hour. Personal keys also draw from an hourly read budget (429 api\_queries\_budget\_exceeded).
* List endpoints page with limit/offset and return next/previous URLs.

## Endpoints

GET

Get the authenticated user

The profile and settings of the user who owns the API key (pass @me).

[Open](#posthog-users-me)

POST

Run a SQL (HogQL) query

Run a HogQL query over events, persons and other tables in a project and get rows back.

[Open](#posthog-query-run)

GET

Get an async query's status and results

Poll a query started with an async refresh mode.

[Open](#posthog-query-get)

GET

List saved insights

Saved insights (trends, funnels, retention, SQL...) with their queries and, unless basic, their results.

[Open](#posthog-insights-list)

GET

Get an insight with its results

One saved insight by numeric id or short\_id, with computed results.

[Open](#posthog-insights-get)

GET

List dashboards

Dashboards in a project with name, description, tags and pinned state.

[Open](#posthog-dashboards-list)

GET

List persons

Persons (identified users) filtered by email, distinct id, search term or properties.

[Open](#posthog-persons-list)

GET

List events

Raw events in a time window, by event name, person or distinct id.

[Open](#posthog-events-list)

GET

List feature flags

Feature flags with key, rollout and filters.

[Open](#posthog-flags-list)

### Get the authenticated user

GET

`/api/users/{uuid}/`

`posthog.users.me`

The profile and settings of the user who owns the API key (pass @me).

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`uuid` required</td><td>string</td><td>path</td><td>@me for the key's own user. Example `@me`</td></tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/)

```python Python theme={null}
router.call_data_api("posthog.users.me", {'uuid': '@me'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.users.me", params={"uuid": "@me"})
```

> [!NOTE]
>
> * Needs user:read.

### Run a SQL (HogQL) query

POST

`/api/projects/{project_id}/query/`

`posthog.query.run`

Run a HogQL query over events, persons and other tables in a project and get rows back.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>
    <tr><td>`query` required</td><td>object</td><td>body</td><td>\{"kind": "HogQLQuery", "query": "\<SQL>"}. Example `{"kind": "HogQLQuery", "query": "SELECT event, count() FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY count() DESC LIMIT 20"}`</td></tr>

    <tr>
      <td>
        `name`
      </td>

      <td>
        string
      </td>

      <td>
        body
      </td>

      <td>
        A label for the query in the query\_log table.
      </td>
    </tr>

    <tr><td>`refresh`</td><td>string</td><td>body</td><td>Execution mode; default blocking. async returns a query id to poll with posthog.query.get. One of `blocking`, `async`, `force_blocking`, `force_async`, `force_cache`, `lazy_async`, `async_except_on_cache_miss`</td></tr>
  </tbody>
</table>

[Vendor docs](https://posthog.com/docs/api/queries) · Same job: [Amplitude](https://docs.webrouter.net/data-apis/amplitude.md#amplitude-charts-query), [Close](https://docs.webrouter.net/data-apis/close-crm.md#close-crm-reports-activity), [Cloudflare](https://docs.webrouter.net/data-apis/cloudflare.md#cloudflare-analytics-graphql), [Google Analytics 4 (Data API)](https://docs.webrouter.net/data-apis/google-analytics.md#google-analytics-report-run), [Instagram Graph API](https://docs.webrouter.net/data-apis/instagram.md#instagram-user-insights), [Klaviyo](https://docs.webrouter.net/data-apis/klaviyo.md#klaviyo-campaigns-report)

```python Python theme={null}
router.call_data_api("posthog.query.run", {'project_id': '12345', 'query': {'kind': 'HogQLQuery', 'query': 'SELECT event, count() FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY count() DESC LIMIT 20'}})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.query.run", params={"project_id": "12345", "query": {"kind": "HogQLQuery", "query": "SELECT event, count() FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY count() DESC LIMIT 20"}})
```

> [!NOTE]
>
> * A read over POST. Needs query:read.
> * Long queries: use refresh async and poll GET /api/projects/\{project\_id}/query/\{id}/.

### Get an async query's status and results

GET

`/api/projects/{project_id}/query/{id}/`

`posthog.query.get`

Poll a query started with an async refresh mode.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>

    <tr>
      <td>
        `id`

        required
      </td>

      <td>
        string
      </td>

      <td>
        path
      </td>

      <td>
        The query id from posthog.query.run.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://posthog.com/docs/api/queries) · Same job: [AI Ark](https://docs.webrouter.net/data-apis/aiark.md#aiark-people-find-emails-status), [AnyAPI](https://docs.webrouter.net/data-apis/anyapi.md#anyapi-requests-get), [Anymail Finder](https://docs.webrouter.net/data-apis/anymailfinder.md#anymailfinder-bulk-get), [Apify](https://docs.webrouter.net/data-apis/apify.md#apify-actors-list), [Aviato](https://docs.webrouter.net/data-apis/aviato.md#aviato-marketmap-get), [BounceBan](https://docs.webrouter.net/data-apis/bounceban.md#bounceban-single-status)

> [!NOTE]
>
> * Needs query:read.

### List saved insights

GET

`/api/projects/{project_id}/insights/`

`posthog.insights.list`

Saved insights (trends, funnels, retention, SQL...) with their queries and, unless basic, their results.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>

    <tr>
      <td>
        `search`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Matches name, description and tags.
      </td>
    </tr>

    <tr><td>`insight`</td><td>string</td><td>query</td><td>Only one insight type. One of `BI`, `FUNNELS`, `JOURNEYS`, `JSON`, `LIFECYCLE`, `PATHS`, `RETENTION`, `SQL`, `STICKINESS`, `TRENDS`</td></tr>

    <tr>
      <td>
        `saved`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Only saved insights (or ones on a visible dashboard).
      </td>
    </tr>

    <tr>
      <td>
        `basic`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Metadata only, no results; faster.
      </td>
    </tr>

    <tr>
      <td>
        `short_id`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        The 8-character id in an insight's URL.
      </td>
    </tr>

    <tr><td>`refresh`</td><td>string</td><td>query</td><td>How to compute results; force\_cache returns cached data only. One of `blocking`, `async`, `force_blocking`, `force_async`, `force_cache`, `lazy_async`, `async_except_on_cache_miss`</td></tr>

    <tr>
      <td>
        `limit`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Results per page.
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Index of the first result; or follow 'next'.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/) · Same job: [Datadog](https://docs.webrouter.net/data-apis/datadog.md#datadog-dashboards-list)

```python Python theme={null}
router.call_data_api("posthog.insights.list", {'project_id': '12345'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.insights.list", params={"project_id": "12345"})
```

> [!NOTE]
>
> * Needs insight:read.

### Get an insight with its results

GET

`/api/projects/{project_id}/insights/{id}/`

`posthog.insights.get`

One saved insight by numeric id or short\_id, with computed results.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>
    <tr><td>`id` required</td><td>string</td><td>path</td><td>Numeric id or 8-character short\_id. Example `AaVQ8Ijw`</td></tr>
    <tr><td>`refresh`</td><td>string</td><td>query</td><td>How aggressively to recompute. One of `blocking`, `async`, `force_blocking`, `force_async`, `force_cache`, `lazy_async`, `async_except_on_cache_miss`</td></tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/) · Same job: [Datadog](https://docs.webrouter.net/data-apis/datadog.md#datadog-dashboards-get)

```python Python theme={null}
router.call_data_api("posthog.insights.get", {'project_id': '12345', 'id': 'AaVQ8Ijw'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.insights.get", params={"project_id": "12345", "id": "AaVQ8Ijw"})
```

> [!NOTE]
>
> * Needs insight:read.

### List dashboards

GET

`/api/projects/{project_id}/dashboards/`

`posthog.dashboards.list`

Dashboards in a project with name, description, tags and pinned state.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>

    <tr>
      <td>
        `search`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Matches name, description and tags.
      </td>
    </tr>

    <tr>
      <td>
        `pinned`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td />
    </tr>

    <tr>
      <td>
        `limit`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Results per page.
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Index of the first result; or follow 'next'.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/) · Same job: [Datadog](https://docs.webrouter.net/data-apis/datadog.md#datadog-dashboards-list)

```python Python theme={null}
router.call_data_api("posthog.dashboards.list", {'project_id': '12345'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.dashboards.list", params={"project_id": "12345"})
```

> [!NOTE]
>
> * Needs dashboard:read.

### List persons

GET

`/api/projects/{project_id}/persons/`

`posthog.persons.list`

Persons (identified users) filtered by email, distinct id, search term or properties.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>

    <tr>
      <td>
        `email`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Exact email.
      </td>
    </tr>

    <tr>
      <td>
        `distinct_id`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td />
    </tr>

    <tr>
      <td>
        `search`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Partial match on email, name, person id or distinct id.
      </td>
    </tr>

    <tr>
      <td>
        `properties`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Person property filters (JSON).
      </td>
    </tr>

    <tr>
      <td>
        `limit`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Results per page.
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Index of the first result; or follow 'next'.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/)

```python Python theme={null}
router.call_data_api("posthog.persons.list", {'project_id': '12345'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.persons.list", params={"project_id": "12345"})
```

> [!NOTE]
>
> * Needs person:read.

### List events

GET

`/api/projects/{project_id}/events/`

`posthog.events.list`

Raw events in a time window, by event name, person or distinct id.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>
    <tr><td>`event`</td><td>string</td><td>query</td><td>Event name. Example `$pageview`</td></tr>

    <tr>
      <td>
        `after`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only events after this time; default 24 hours ago.
      </td>
    </tr>

    <tr>
      <td>
        `before`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only events before this time; default now.
      </td>
    </tr>

    <tr>
      <td>
        `distinct_id`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td />
    </tr>

    <tr>
      <td>
        `person_id`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td />
    </tr>

    <tr>
      <td>
        `properties`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Event/person property filters (JSON).
      </td>
    </tr>

    <tr>
      <td>
        `limit`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td />
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Fails above 100,000; page by time instead.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/) · Same job: [Benzinga](https://docs.webrouter.net/data-apis/benzinga.md#benzinga-earnings), [Datadog](https://docs.webrouter.net/data-apis/datadog.md#datadog-events-list), [Financial Modeling Prep](https://docs.webrouter.net/data-apis/fmp.md#fmp-earnings-calendar), [FRED (St. Louis Fed)](https://docs.webrouter.net/data-apis/fred.md#fred-releases-dates), [Kalshi](https://docs.webrouter.net/data-apis/kalshi.md#kalshi-events-list), [Legistar Web API](https://docs.webrouter.net/data-apis/legistar.md#legistar-events-list)

```python Python theme={null}
router.call_data_api("posthog.events.list", {'project_id': '12345', 'event': '$pageview'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.events.list", params={"project_id": "12345", "event": "$pageview"})
```

> [!NOTE]
>
> * Needs query:read. For aggregates use posthog.query.run.

### List feature flags

GET

`/api/projects/{project_id}/feature_flags/`

`posthog.flags.list`

Feature flags with key, rollout and filters.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id` required</td><td>string</td><td>path</td><td>Project id, from the project's settings page or URL. Example `12345`</td></tr>

    <tr>
      <td>
        `search`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Key or name.
      </td>
    </tr>

    <tr>
      <td>
        `key`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Exact key.
      </td>
    </tr>

    <tr>
      <td>
        `active`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        &#x20;One of&#x20;

        `true`

        ,&#x20;

        `false`

        ,&#x20;

        `STALE`
      </td>
    </tr>

    <tr>
      <td>
        `type`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        &#x20;One of&#x20;

        `boolean`

        ,&#x20;

        `experiment`

        ,&#x20;

        `multivariant`

        ,&#x20;

        `remote_config`
      </td>
    </tr>

    <tr>
      <td>
        `limit`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Results per page.
      </td>
    </tr>

    <tr>
      <td>
        `offset`
      </td>

      <td>
        integer
      </td>

      <td>
        query
      </td>

      <td>
        Index of the first result; or follow 'next'.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://us.posthog.com/api/schema/)

```python Python theme={null}
router.call_data_api("posthog.flags.list", {'project_id': '12345'})
```

```text MCP theme={null}
call_data_api(endpoint="posthog.flags.list", params={"project_id": "12345"})
```

> [!NOTE]
>
> * Needs feature\_flag:read.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.