Product

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

GET
POST
GET
PATCH
DELETE
GET
GET
GET
POST
GET
PATCH
DELETE
GET
GET
GET
POST
GET
POST

List all environments elements

Required API key scopes

element:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

GET /api/environments/:environment_id/elements
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}
]
}

Create environments elements

Required API key scopes

element:write

Request parameters

  • text
    stringnull
  • tag_name
    stringnull
  • attr_class
    arraynull
  • href
    stringnull
  • attr_id
    stringnull
  • nth_child
    integernull
  • nth_of_type
    integernull
  • attributes
  • order
    integernull

Response


Example request

POST /api/environments/:environment_id/elements
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/\
-d text=["string","null"]

Example response

Status 201
RESPONSE
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}

Retrieve environments elements

Required API key scopes

element:read

Path parameters

  • id
    integer

Response


Example request

GET /api/environments/:environment_id/elements/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/:id/

Example response

Status 200
RESPONSE
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}

Update environments elements

Required API key scopes

element:write

Path parameters

  • id
    integer

Request parameters

  • text
    stringnull
  • tag_name
    stringnull
  • attr_class
    arraynull
  • href
    stringnull
  • attr_id
    stringnull
  • nth_child
    integernull
  • nth_of_type
    integernull
  • attributes
  • order
    integernull

Response


Example request

PATCH /api/environments/:environment_id/elements/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/:id/\
-d text=["string","null"]

Example response

Status 200
RESPONSE
{
"text": "string",
"tag_name": "string",
"attr_class": [
"string"
],
"href": "string",
"attr_id": "string",
"nth_child": -2147483648,
"nth_of_type": -2147483648,
"attributes": null,
"order": -2147483648
}

Delete environments elements

Required API key scopes

element:write

Path parameters

  • id
    integer

Example request

DELETE /api/environments/:environment_id/elements/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/:id/

Example response

Status 204 No response body

Retrieve environments 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:read

Example request

GET /api/environments/:environment_id/elements/stats
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/stats/

Example response

Status 200 No response body

Retrieve environments elements values

Required API key scopes

element:read

Example request

GET /api/environments/:environment_id/elements/values
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/elements/values/

Example response

Status 200 No response body

List all environments insights

Also available via the PostHog MCP server:

  • insights-listGet 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:read

Query parameters

  • basic
    boolean
  • created_by
    string
  • created_date_from
    string
  • created_date_to
    string
  • dashboards
    string
  • date_from
    string
  • date_to
    string
  • favorited
    boolean
  • format
    string
    One of: "csv""json"
  • insight
    string
    One of: "FUNNELS""JSON""LIFECYCLE""PATHS""RETENTION""SQL""STICKINESS""TRENDS"
  • last_viewed_date_from
    string
  • last_viewed_date_to
    string
  • limit
    integer
  • offset
    integer
  • refresh
    string
    Default: force_cache
    One of: "async""async_except_on_cache_miss""blocking""force_async""force_blocking""force_cache""lazy_async"
  • saved
    boolean
  • search
    string
  • short_id
    string
  • tags
    string
  • user
    boolean

Response


Example request

GET /api/environments/:environment_id/insights
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": 0,
"short_id": "string",
"name": "string",
"derived_name": "string",
"query": {
"embedded": null,
"full": null,
"hidePersonsModal": null,
"hideTooltipOnScroll": null,
"kind": "InsightVizNode",
"showCorrelationTable": null,
"showFilters": null,
"showHeader": null,
"showLastComputation": null,
"showLastComputationRefresh": null,
"showResults": null,
"showTable": null,
"source": {
"aggregation_group_type_index": null,
"breakdownFilter": null,
"compareFilter": null,
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": null,
"filterTestAccounts": false,
"interval": "day",
"kind": "TrendsQuery",
"modifiers": null,
"properties": [],
"response": null,
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"operator": "AND",
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"tags": null,
"trendsFilter": null,
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": null
},
"order": -2147483648,
"deleted": true,
"dashboards": [
0
],
"dashboard_tiles": [
{
"id": 0,
"dashboard_id": 0,
"deleted": true
}
],
"last_refresh": "2019-08-24T14:15:22Z",
"cache_target_age": "2019-08-24T14:15:22Z",
"next_allowed_client_refresh": "2019-08-24T14:15:22Z",
"result": null,
"hasMore": true,
"columns": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"description": "string",
"updated_at": "2019-08-24T14:15:22Z",
"tags": [
null
],
"favorited": true,
"last_modified_at": "2019-08-24T14:15:22Z",
"last_modified_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"is_sample": true,
"effective_restriction_level": 21,
"effective_privilege_level": 21,
"user_access_level": "string",
"timezone": "string",
"is_cached": true,
"query_status": null,
"hogql": "string",
"types": [
null
],
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"_create_in_folder": "string",
"alerts": [
null
],
"last_viewed_at": "2019-08-24T14:15:22Z"
}
]
}

Create environments insights

Also available via the PostHog MCP server:

  • insight-createCreate 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:write

Query parameters

  • format
    string
    One of: "csv""json"

Request parameters

  • name
    stringnull
  • derived_name
    stringnull
  • query
  • order
    integernull
  • deleted
    boolean
  • dashboards
    array
  • description
    stringnull
  • tags
    array
  • favorited
    boolean
  • _create_in_folder
    string

Response


Example request

POST /api/environments/:environment_id/insights
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/\
-d name=["string","null"]

Example response

Status 201
RESPONSE
{
"id": 0,
"short_id": "string",
"name": "string",
"derived_name": "string",
"query": {
"embedded": null,
"full": null,
"hidePersonsModal": null,
"hideTooltipOnScroll": null,
"kind": "InsightVizNode",
"showCorrelationTable": null,
"showFilters": null,
"showHeader": null,
"showLastComputation": null,
"showLastComputationRefresh": null,
"showResults": null,
"showTable": null,
"source": {
"aggregation_group_type_index": null,
"breakdownFilter": null,
"compareFilter": null,
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": null,
"filterTestAccounts": false,
"interval": "day",
"kind": "TrendsQuery",
"modifiers": null,
"properties": [],
"response": null,
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"operator": "AND",
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"tags": null,
"trendsFilter": null,
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": null
},
"order": -2147483648,
"deleted": true,
"dashboards": [
0
],
"dashboard_tiles": [
{
"id": 0,
"dashboard_id": 0,
"deleted": true
}
],
"last_refresh": "2019-08-24T14:15:22Z",
"cache_target_age": "2019-08-24T14:15:22Z",
"next_allowed_client_refresh": "2019-08-24T14:15:22Z",
"result": null,
"hasMore": true,
"columns": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"description": "string",
"updated_at": "2019-08-24T14:15:22Z",
"tags": [
null
],
"favorited": true,
"last_modified_at": "2019-08-24T14:15:22Z",
"last_modified_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"is_sample": true,
"effective_restriction_level": 21,
"effective_privilege_level": 21,
"user_access_level": "string",
"timezone": "string",
"is_cached": true,
"query_status": null,
"hogql": "string",
"types": [
null
],
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"_create_in_folder": "string",
"alerts": [
null
],
"last_viewed_at": "2019-08-24T14:15:22Z"
}

Retrieve environments insights

Also available via the PostHog MCP server:

  • insight-getGet 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:read

Path parameters

  • id

Query parameters

  • filters_override
    string
  • format
    string
    One of: "csv""json"
  • from_dashboard
    integer
  • refresh
    string
    Default: force_cache
    One of: "async""async_except_on_cache_miss""blocking""force_async""force_blocking""force_cache""lazy_async"
  • variables_override
    string

Response


Example request

GET /api/environments/:environment_id/insights/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/

Example response

Status 200
RESPONSE
{
"id": 0,
"short_id": "string",
"name": "string",
"derived_name": "string",
"query": {
"embedded": null,
"full": null,
"hidePersonsModal": null,
"hideTooltipOnScroll": null,
"kind": "InsightVizNode",
"showCorrelationTable": null,
"showFilters": null,
"showHeader": null,
"showLastComputation": null,
"showLastComputationRefresh": null,
"showResults": null,
"showTable": null,
"source": {
"aggregation_group_type_index": null,
"breakdownFilter": null,
"compareFilter": null,
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": null,
"filterTestAccounts": false,
"interval": "day",
"kind": "TrendsQuery",
"modifiers": null,
"properties": [],
"response": null,
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"operator": "AND",
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"tags": null,
"trendsFilter": null,
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": null
},
"order": -2147483648,
"deleted": true,
"dashboards": [
0
],
"dashboard_tiles": [
{
"id": 0,
"dashboard_id": 0,
"deleted": true
}
],
"last_refresh": "2019-08-24T14:15:22Z",
"cache_target_age": "2019-08-24T14:15:22Z",
"next_allowed_client_refresh": "2019-08-24T14:15:22Z",
"result": null,
"hasMore": true,
"columns": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"description": "string",
"updated_at": "2019-08-24T14:15:22Z",
"tags": [
null
],
"favorited": true,
"last_modified_at": "2019-08-24T14:15:22Z",
"last_modified_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"is_sample": true,
"effective_restriction_level": 21,
"effective_privilege_level": 21,
"user_access_level": "string",
"timezone": "string",
"is_cached": true,
"query_status": null,
"hogql": "string",
"types": [
null
],
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"_create_in_folder": "string",
"alerts": [
null
],
"last_viewed_at": "2019-08-24T14:15:22Z"
}

Update environments insights

Also available via the PostHog MCP server:

  • insight-updateUpdate 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:write

Path parameters

  • id

Query parameters

  • format
    string
    One of: "csv""json"

Request parameters

  • name
    stringnull
  • derived_name
    stringnull
  • query
  • order
    integernull
  • deleted
    boolean
  • dashboards
    array
  • description
    stringnull
  • tags
    array
  • favorited
    boolean
  • _create_in_folder
    string

Response


Example request

PATCH /api/environments/:environment_id/insights/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/\
-d name=["string","null"]

Example response

Status 200
RESPONSE
{
"id": 0,
"short_id": "string",
"name": "string",
"derived_name": "string",
"query": {
"embedded": null,
"full": null,
"hidePersonsModal": null,
"hideTooltipOnScroll": null,
"kind": "InsightVizNode",
"showCorrelationTable": null,
"showFilters": null,
"showHeader": null,
"showLastComputation": null,
"showLastComputationRefresh": null,
"showResults": null,
"showTable": null,
"source": {
"aggregation_group_type_index": null,
"breakdownFilter": null,
"compareFilter": null,
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": null,
"filterTestAccounts": false,
"interval": "day",
"kind": "TrendsQuery",
"modifiers": null,
"properties": [],
"response": null,
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": null,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": null,
"math_property_type": null,
"name": null,
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"operator": "AND",
"optionalInFunnel": null,
"orderBy": null,
"properties": null,
"response": null,
"version": null
}
],
"tags": null,
"trendsFilter": null,
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": null
},
"order": -2147483648,
"deleted": true,
"dashboards": [
0
],
"dashboard_tiles": [
{
"id": 0,
"dashboard_id": 0,
"deleted": true
}
],
"last_refresh": "2019-08-24T14:15:22Z",
"cache_target_age": "2019-08-24T14:15:22Z",
"next_allowed_client_refresh": "2019-08-24T14:15:22Z",
"result": null,
"hasMore": true,
"columns": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"description": "string",
"updated_at": "2019-08-24T14:15:22Z",
"tags": [
null
],
"favorited": true,
"last_modified_at": "2019-08-24T14:15:22Z",
"last_modified_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"is_sample": true,
"effective_restriction_level": 21,
"effective_privilege_level": 21,
"user_access_level": "string",
"timezone": "string",
"is_cached": true,
"query_status": null,
"hogql": "string",
"types": [
null
],
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"_create_in_folder": "string",
"alerts": [
null
],
"last_viewed_at": "2019-08-24T14:15:22Z"
}

Delete environments insights

Also available via the PostHog MCP server:

  • insight-deleteDelete insight

Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true

Required API key scopes

insight:write

Path parameters

  • id

Query parameters

  • format
    string
    One of: "csv""json"

Example request

DELETE /api/environments/:environment_id/insights/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/

Example response

Status 405 No response body

Retrieve environments insights activity

Also available via the PostHog MCP server:

  • insights-activity-retrieveGet 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:read

Path parameters

  • id
    integer

Query parameters

  • format
    string
    One of: "csv""json"
  • limit
    integer
  • page
    integer

Response


Example request

GET /api/environments/:environment_id/insights/:id/activity
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/activity/

Example response

Status 200
RESPONSE
{
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"user": {},
"activity": "string",
"scope": "string",
"item_id": "string",
"detail": {
"id": "string",
"changes": [
{
"type": "string",
"action": "string",
"field": "string",
"before": null,
"after": null
}
],
"merge": {
"type": "string",
"source": null,
"target": null
},
"trigger": {
"job_type": "string",
"job_id": "string",
"payload": null
},
"name": "string",
"short_id": "string",
"type": "string"
},
"created_at": "2019-08-24T14:15:22Z"
}
],
"next": "http://example.com",
"previous": "http://example.com",
"total_count": 0
}

Retrieve environments insights analyze

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.

Path parameters

  • id
    integer

Query parameters

  • format
    string
    One of: "csv""json"

Example request

GET /api/environments/:environment_id/insights/:id/analyze
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/analyze/

Example response

Status 200 No response body

Retrieve environments insights suggestions

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.

Path parameters

  • id
    integer

Query parameters

  • format
    string
    One of: "csv""json"

Example request

GET /api/environments/:environment_id/insights/:id/suggestions
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/suggestions/

Example response

Status 200 No response body

Create environments insights suggestions

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.

Path parameters

  • id
    integer

Query parameters

  • format
    string
    One of: "csv""json"

Request parameters

  • name
    stringnull
  • derived_name
    stringnull
  • query
  • order
    integernull
  • deleted
    boolean
  • dashboards
    array
  • description
    stringnull
  • tags
    array
  • favorited
    boolean
  • _create_in_folder
    string

Example request

POST /api/environments/:environment_id/insights/:id/suggestions
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/:id/suggestions/\
-d name=["string","null"]

Example response

Status 200 No response body

Retrieve environments insights all activity

Also available via the PostHog MCP server:

  • insights-all-activity-retrieveGet recent insight activity across the project

Project-wide audit trail across all insights — who created, edited, deleted, or restored insights, what changed (with before/after diffs), and when. Useful for surfacing what people (or agents) have been working on recently.

Required API key scopes

activity_log:read

Query parameters

  • format
    string
    One of: "csv""json"
  • limit
    integer
  • page
    integer

Response


Example request

GET /api/environments/:environment_id/insights/activity
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/activity/

Example response

Status 200
RESPONSE
{
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"user": {},
"activity": "string",
"scope": "string",
"item_id": "string",
"detail": {
"id": "string",
"changes": [
{
"type": "string",
"action": "string",
"field": "string",
"before": null,
"after": null
}
],
"merge": {
"type": "string",
"source": null,
"target": null
},
"trigger": {
"job_type": "string",
"job_id": "string",
"payload": null
},
"name": "string",
"short_id": "string",
"type": "string"
},
"created_at": "2019-08-24T14:15:22Z"
}
],
"next": "http://example.com",
"previous": "http://example.com",
"total_count": 0
}

Create environments insights bulk update tags

Bulk update tags on multiple objects.

PAT access: this action has no required_scopes= on the decorator — inheriting viewsets must add "bulk_update_tags" to their scope_object_write_actions list to accept personal API keys. Without that opt-in, APIScopePermission rejects PAT requests with "This action does not support personal API key access". Done per-viewset so granting <scope>:write for one resource doesn't leak access to sibling resources that share this mixin.

Accepts:

  • {"ids": [...], "action": "add"|"remove"|"set", "tags": ["tag1", "tag2"]}

Actions:

  • "add": Add tags to existing tags on each object
  • "remove": Remove specific tags from each object
  • "set": Replace all tags on each object with the provided list

Query parameters

  • format
    string
    One of: "csv""json"

Request parameters

  • ids
    array
  • action
  • tags
    array

Response


Example request

POST /api/environments/:environment_id/insights/bulk_update_tags
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/insights/bulk_update_tags/\
-d ids="array",\
-d action=undefined,\
-d tags="array"

Example response

Status 200
RESPONSE
{
"updated": [
{
"id": 0,
"tags": [
"string"
]
}
],
"skipped": [
{
"id": 0,
"reason": "string"
}
]
}

Community questions

Questions about this page? or post a community question.