Product
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
POST | |
POST | |
GET | |
GET | |
POST | |
GET | |
POST | |
GET | |
PATCH | |
DELETE | |
GET | |
GET | |
GET | |
POST | |
GET | |
PATCH | |
DELETE | |
GET |
Create environments insights cancel
DRF ViewSet mixin that gates coalesced responses behind permission checks.
The QueryCoalescingMiddleware attaches cached response data to request.META["_coalesced_response"] for followers. This mixin runs DRF's initial() (auth + permissions + throttling) before returning the cached response, ensuring the request is authorized.
Query parameters
- formatstringOne of:
"csv""json"
Request parameters
- namestringnull
- derived_namestringnull
- query
- orderintegernull
- deletedboolean
- dashboardsarray
- descriptionstringnull
- tagsarray
- favoritedboolean
- _create_in_folderstring
Example request
POST /api /environments /:environment_id /insights /cancelExample response
Status 200 No response body
Create environments insights generate metadata
Generate an AI-suggested name and description for an insight based on its query configuration.
Required API key scopes
insight:writeQuery parameters
- formatstringOne of:
"csv""json"
Request parameters
- namestringnull
- derived_namestringnull
- query
- orderintegernull
- deletedboolean
- dashboardsarray
- descriptionstringnull
- tagsarray
- favoritedboolean
- _create_in_folderstring
Example request
POST /api /environments /:environment_id /insights /generate_metadataExample response
Status 200 No response body
Retrieve environments insights my last viewed
Returns basic details about the last 5 insights viewed by this user. Most recently viewed first.
Query parameters
- formatstringOne of:
"csv""json"
Example request
GET /api /environments /:environment_id /insights /my_last_viewedExample response
Status 200 No response body
Retrieve environments insights trending
Also available via the PostHog MCP server:
insights-trending-retrieve— Get most-viewed insights
Returns insights ranked by view count over the last N days (default 7), highest first. Each result includes the same metadata as the standard insights list, plus a view_count and up to 3 recent viewers. Useful for surfacing the most-used insights in a project.
Required API key scopes
insight:readQuery parameters
- daysinteger
- formatstringOne of:
"csv""json" - limitinteger
- offsetinteger
Response
Example request
GET /api /environments /:environment_id /insights /trendingExample response
Status 200
Create environments insights viewed
Record that the current user has just viewed one or more insights. Submitted ids that do not belong to the current project or that point at deleted insights are silently dropped. Returns 201 on success regardless of how many ids were retained.
Required API key scopes
insight:readQuery parameters
- formatstringOne of:
"csv""json"
Request parameters
- insight_idsarray
Example request
POST /api /environments /:environment_id /insights /viewedExample response
Status 201 Views recorded.
List all elements
Required API key scopes
element:readQuery parameters
- limitinteger
- offsetinteger
Response
Example request
GET /api /projects /:project_id /elementsExample response
Status 200
Create elements
Required API key scopes
element:writeRequest parameters
- textstringnull
- tag_namestringnull
- attr_classarraynull
- hrefstringnull
- attr_idstringnull
- nth_childintegernull
- nth_of_typeintegernull
- attributes
- orderintegernull
Response
Example request
POST /api /projects /:project_id /elementsExample response
Status 201
Retrieve elements
Required API key scopes
element:readPath parameters
- idinteger
Response
Example request
GET /api /projects /:project_id /elements /:idExample response
Status 200
Update elements
Required API key scopes
element:writePath parameters
- idinteger
Request parameters
- textstringnull
- tag_namestringnull
- attr_classarraynull
- hrefstringnull
- attr_idstringnull
- nth_childintegernull
- nth_of_typeintegernull
- attributes
- orderintegernull
Response
Example request
PATCH /api /projects /:project_id /elements /:idExample response
Status 200
Delete elements
Required API key scopes
element:writePath parameters
- idinteger
Example request
DELETE /api /projects /:project_id /elements /:idExample response
Status 204 No response body
Retrieve elements stats
The original version of this API always and only returned $autocapture elements If no include query parameter is sent this remains true. Now, you can pass a combination of include query parameters to get different types of elements Currently only $autocapture and $rageclick and $dead_click are supported
Required API key scopes
element:readExample request
GET /api /projects /:project_id /elements /statsExample response
Status 200 No response body
Retrieve elements values
Required API key scopes
element:readExample request
GET /api /projects /:project_id /elements /valuesExample response
Status 200 No response body
List all insights
Also available via the PostHog MCP server:
insights-list— Get all insights
DRF ViewSet mixin that gates coalesced responses behind permission checks.
The QueryCoalescingMiddleware attaches cached response data to request.META["_coalesced_response"] for followers. This mixin runs DRF's initial() (auth + permissions + throttling) before returning the cached response, ensuring the request is authorized.
Required API key scopes
insight:readQuery parameters
- basicboolean
- created_bystring
- created_date_fromstring
- created_date_tostring
- dashboardsstring
- date_fromstring
- date_tostring
- favoritedboolean
- formatstringOne of:
"csv""json" - insightstringOne of:
"FUNNELS""JSON""LIFECYCLE""PATHS""RETENTION""SQL""STICKINESS""TRENDS" - last_viewed_date_fromstring
- last_viewed_date_tostring
- limitinteger
- offsetinteger
- refreshstringDefault:
force_cacheOne of:"async""async_except_on_cache_miss""blocking""force_async""force_blocking""force_cache""lazy_async" - savedboolean
- searchstring
- short_idstring
- tagsstring
- userboolean
Response
Example request
GET /api /projects /:project_id /insightsExample response
Status 200
Create insights
Also available via the PostHog MCP server:
insight-create— Create insight
DRF ViewSet mixin that gates coalesced responses behind permission checks.
The QueryCoalescingMiddleware attaches cached response data to request.META["_coalesced_response"] for followers. This mixin runs DRF's initial() (auth + permissions + throttling) before returning the cached response, ensuring the request is authorized.
Required API key scopes
insight:writeQuery parameters
- formatstringOne of:
"csv""json"
Request parameters
- namestringnull
- derived_namestringnull
- query
- orderintegernull
- deletedboolean
- dashboardsarray
- descriptionstringnull
- tagsarray
- favoritedboolean
- _create_in_folderstring
Response
Example request
POST /api /projects /:project_id /insightsExample response
Status 201
Retrieve insights
Also available via the PostHog MCP server:
insight-get— Get insight
DRF ViewSet mixin that gates coalesced responses behind permission checks.
The QueryCoalescingMiddleware attaches cached response data to request.META["_coalesced_response"] for followers. This mixin runs DRF's initial() (auth + permissions + throttling) before returning the cached response, ensuring the request is authorized.
Required API key scopes
insight:readPath parameters
- id
Query parameters
- filters_overridestring
- formatstringOne of:
"csv""json" - from_dashboardinteger
- refreshstringDefault:
force_cacheOne of:"async""async_except_on_cache_miss""blocking""force_async""force_blocking""force_cache""lazy_async" - variables_overridestring
Response
Example request
GET /api /projects /:project_id /insights /:idExample response
Status 200
Update insights
Also available via the PostHog MCP server:
insight-update— Update insight
DRF ViewSet mixin that gates coalesced responses behind permission checks.
The QueryCoalescingMiddleware attaches cached response data to request.META["_coalesced_response"] for followers. This mixin runs DRF's initial() (auth + permissions + throttling) before returning the cached response, ensuring the request is authorized.
Required API key scopes
insight:writePath parameters
- id
Query parameters
- formatstringOne of:
"csv""json"
Request parameters
- namestringnull
- derived_namestringnull
- query
- orderintegernull
- deletedboolean
- dashboardsarray
- descriptionstringnull
- tagsarray
- favoritedboolean
- _create_in_folderstring
Response
Example request
PATCH /api /projects /:project_id /insights /:idExample response
Status 200
Delete insights
Also available via the PostHog MCP server:
insight-delete— Delete insight
Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true
Required API key scopes
insight:writePath parameters
- id
Query parameters
- formatstringOne of:
"csv""json"
Example request
DELETE /api /projects /:project_id /insights /:idExample response
Status 405 No response body
Retrieve insights activity
Also available via the PostHog MCP server:
insights-activity-retrieve— Get insight activity log
Audit trail for a single insight — every change made to it, by whom, and when. Use this when you want the change history of a specific insight; use the project-wide activity endpoint for a broader view.
Required API key scopes
activity_log:readPath parameters
- idinteger
Query parameters
- formatstringOne of:
"csv""json" - limitinteger
- pageinteger
Response
Example request
GET /api /projects /:project_id /insights /:id /activity