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

Path parameters

  • environment_id
    string

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

Path parameters

  • environment_id
    string

Request parameters

  • text
    string
  • tag_name
    string
  • attr_class
    array
  • href
    string
  • attr_id
    string
  • nth_child
    integer
  • nth_of_type
    integer
  • attributes
  • order
    integer

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"

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

  • environment_id
    string
  • 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

  • environment_id
    string
  • id
    integer

Request parameters

  • text
    string
  • tag_name
    string
  • attr_class
    array
  • href
    string
  • attr_id
    string
  • nth_child
    integer
  • nth_of_type
    integer
  • attributes
  • order
    integer

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"

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

  • environment_id
    string
  • 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

Path parameters

  • environment_id
    string

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

Path parameters

  • environment_id
    string

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

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

  • environment_id
    string

Query parameters

  • basic
    boolean
  • format
    string
    One of: "csv""json"
  • 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"
  • short_id
    string

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": {
"breakdown": null,
"breakdown_group_type_index": null,
"breakdown_hide_other_aggregation": null,
"breakdown_histogram_bin_count": null,
"breakdown_limit": null,
"breakdown_normalize_url": null,
"breakdown_path_cleaning": null,
"breakdown_type": "cohort",
"breakdowns": null
},
"compareFilter": {
"compare": false,
"compare_to": null
},
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": {
"date_from": null,
"date_to": null,
"explicitDate": false
},
"filterTestAccounts": false,
"interval": "second",
"kind": "TrendsQuery",
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"properties": [],
"response": {
"boxplot_data": null,
"error": null,
"hasMore": null,
"hogql": null,
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"query_status": {
"complete": false,
"dashboard_id": null,
"end_time": null,
"error": false,
"error_message": null,
"expiration_time": null,
"id": "string",
"insight_id": null,
"labels": null,
"pickup_time": null,
"query_async": true,
"query_progress": {
"active_cpu_time": 0,
"bytes_read": 0,
"estimated_rows_total": 0,
"rows_read": 0,
"time_elapsed": 0
},
"results": null,
"start_time": null,
"task_id": null,
"team_id": 0
},
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"results": [
{}
],
"timings": null
},
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"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": {
"name": null,
"productKey": null,
"scene": null
},
"trendsFilter": {
"aggregationAxisFormat": "numeric",
"aggregationAxisPostfix": null,
"aggregationAxisPrefix": null,
"breakdown_histogram_bin_count": null,
"confidenceLevel": null,
"decimalPlaces": null,
"detailedResultsAggregationType": "total",
"display": "Auto",
"excludeBoxPlotOutliers": true,
"formula": null,
"formulaNodes": null,
"formulas": null,
"goalLines": null,
"hiddenLegendIndexes": null,
"hideWeekends": false,
"minDecimalPlaces": null,
"movingAverageIntervals": null,
"resultCustomizationBy": "value",
"resultCustomizations": null,
"showAlertThresholdLines": false,
"showConfidenceIntervals": null,
"showLabelsOnSeries": null,
"showLegend": false,
"showMovingAverage": null,
"showMultipleYAxes": false,
"showPercentStackView": false,
"showTrendLines": null,
"showValuesOnSeries": false,
"smoothingIntervals": 1,
"yAxisScaleType": "log10"
},
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": {
"ActionsPie": {
"disableHoverOffset": null,
"hideAggregation": null
},
"RETENTION": {
"hideLineGraph": null,
"hideSizeColumn": null,
"useSmallLayout": 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": {
"property1": null,
"property2": null
},
"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": {
"property1": null,
"property2": null
},
"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

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

  • environment_id
    string

Query parameters

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

Request parameters

  • name
    string
  • derived_name
    string
  • query
  • order
    integer
  • deleted
    boolean
  • dashboards
    array
  • description
    string
  • 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"

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": {
"breakdown": null,
"breakdown_group_type_index": null,
"breakdown_hide_other_aggregation": null,
"breakdown_histogram_bin_count": null,
"breakdown_limit": null,
"breakdown_normalize_url": null,
"breakdown_path_cleaning": null,
"breakdown_type": "cohort",
"breakdowns": null
},
"compareFilter": {
"compare": false,
"compare_to": null
},
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": {
"date_from": null,
"date_to": null,
"explicitDate": false
},
"filterTestAccounts": false,
"interval": "second",
"kind": "TrendsQuery",
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"properties": [],
"response": {
"boxplot_data": null,
"error": null,
"hasMore": null,
"hogql": null,
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"query_status": {
"complete": false,
"dashboard_id": null,
"end_time": null,
"error": false,
"error_message": null,
"expiration_time": null,
"id": "string",
"insight_id": null,
"labels": null,
"pickup_time": null,
"query_async": true,
"query_progress": {
"active_cpu_time": 0,
"bytes_read": 0,
"estimated_rows_total": 0,
"rows_read": 0,
"time_elapsed": 0
},
"results": null,
"start_time": null,
"task_id": null,
"team_id": 0
},
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"results": [
{}
],
"timings": null
},
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"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": {
"name": null,
"productKey": null,
"scene": null
},
"trendsFilter": {
"aggregationAxisFormat": "numeric",
"aggregationAxisPostfix": null,
"aggregationAxisPrefix": null,
"breakdown_histogram_bin_count": null,
"confidenceLevel": null,
"decimalPlaces": null,
"detailedResultsAggregationType": "total",
"display": "Auto",
"excludeBoxPlotOutliers": true,
"formula": null,
"formulaNodes": null,
"formulas": null,
"goalLines": null,
"hiddenLegendIndexes": null,
"hideWeekends": false,
"minDecimalPlaces": null,
"movingAverageIntervals": null,
"resultCustomizationBy": "value",
"resultCustomizations": null,
"showAlertThresholdLines": false,
"showConfidenceIntervals": null,
"showLabelsOnSeries": null,
"showLegend": false,
"showMovingAverage": null,
"showMultipleYAxes": false,
"showPercentStackView": false,
"showTrendLines": null,
"showValuesOnSeries": false,
"smoothingIntervals": 1,
"yAxisScaleType": "log10"
},
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": {
"ActionsPie": {
"disableHoverOffset": null,
"hideAggregation": null
},
"RETENTION": {
"hideLineGraph": null,
"hideSizeColumn": null,
"useSmallLayout": 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": {
"property1": null,
"property2": null
},
"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": {
"property1": null,
"property2": null
},
"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

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

  • environment_id
    string
  • id

Query parameters

  • 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"

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": {
"breakdown": null,
"breakdown_group_type_index": null,
"breakdown_hide_other_aggregation": null,
"breakdown_histogram_bin_count": null,
"breakdown_limit": null,
"breakdown_normalize_url": null,
"breakdown_path_cleaning": null,
"breakdown_type": "cohort",
"breakdowns": null
},
"compareFilter": {
"compare": false,
"compare_to": null
},
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": {
"date_from": null,
"date_to": null,
"explicitDate": false
},
"filterTestAccounts": false,
"interval": "second",
"kind": "TrendsQuery",
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"properties": [],
"response": {
"boxplot_data": null,
"error": null,
"hasMore": null,
"hogql": null,
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"query_status": {
"complete": false,
"dashboard_id": null,
"end_time": null,
"error": false,
"error_message": null,
"expiration_time": null,
"id": "string",
"insight_id": null,
"labels": null,
"pickup_time": null,
"query_async": true,
"query_progress": {
"active_cpu_time": 0,
"bytes_read": 0,
"estimated_rows_total": 0,
"rows_read": 0,
"time_elapsed": 0
},
"results": null,
"start_time": null,
"task_id": null,
"team_id": 0
},
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"results": [
{}
],
"timings": null
},
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"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": {
"name": null,
"productKey": null,
"scene": null
},
"trendsFilter": {
"aggregationAxisFormat": "numeric",
"aggregationAxisPostfix": null,
"aggregationAxisPrefix": null,
"breakdown_histogram_bin_count": null,
"confidenceLevel": null,
"decimalPlaces": null,
"detailedResultsAggregationType": "total",
"display": "Auto",
"excludeBoxPlotOutliers": true,
"formula": null,
"formulaNodes": null,
"formulas": null,
"goalLines": null,
"hiddenLegendIndexes": null,
"hideWeekends": false,
"minDecimalPlaces": null,
"movingAverageIntervals": null,
"resultCustomizationBy": "value",
"resultCustomizations": null,
"showAlertThresholdLines": false,
"showConfidenceIntervals": null,
"showLabelsOnSeries": null,
"showLegend": false,
"showMovingAverage": null,
"showMultipleYAxes": false,
"showPercentStackView": false,
"showTrendLines": null,
"showValuesOnSeries": false,
"smoothingIntervals": 1,
"yAxisScaleType": "log10"
},
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": {
"ActionsPie": {
"disableHoverOffset": null,
"hideAggregation": null
},
"RETENTION": {
"hideLineGraph": null,
"hideSizeColumn": null,
"useSmallLayout": 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": {
"property1": null,
"property2": null
},
"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": {
"property1": null,
"property2": null
},
"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

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

  • environment_id
    string
  • id

Query parameters

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

Request parameters

  • name
    string
  • derived_name
    string
  • query
  • order
    integer
  • deleted
    boolean
  • dashboards
    array
  • description
    string
  • 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"

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": {
"breakdown": null,
"breakdown_group_type_index": null,
"breakdown_hide_other_aggregation": null,
"breakdown_histogram_bin_count": null,
"breakdown_limit": null,
"breakdown_normalize_url": null,
"breakdown_path_cleaning": null,
"breakdown_type": "cohort",
"breakdowns": null
},
"compareFilter": {
"compare": false,
"compare_to": null
},
"conversionGoal": null,
"dataColorTheme": null,
"dateRange": {
"date_from": null,
"date_to": null,
"explicitDate": false
},
"filterTestAccounts": false,
"interval": "second",
"kind": "TrendsQuery",
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"properties": [],
"response": {
"boxplot_data": null,
"error": null,
"hasMore": null,
"hogql": null,
"modifiers": {
"bounceRateDurationSeconds": null,
"bounceRatePageViewMode": "count_pageviews",
"convertToProjectTimezone": null,
"customChannelTypeRules": null,
"dataWarehouseEventsModifiers": null,
"debug": null,
"forceClickhouseDataSkippingIndexes": null,
"formatCsvAllowDoubleQuotes": null,
"inCohortVia": "auto",
"inlineCohortCalculation": "off",
"materializationMode": "auto",
"materializedColumnsOptimizationMode": "disabled",
"optimizeJoinedFilters": null,
"optimizeProjections": null,
"personsArgMaxVersion": "auto",
"personsJoinMode": "inner",
"personsOnEventsMode": "disabled",
"propertyGroupsMode": "enabled",
"s3TableUseInvalidColumns": null,
"sessionTableVersion": "auto",
"sessionsV2JoinMode": "string",
"timings": null,
"useMaterializedViews": null,
"usePreaggregatedIntermediateResults": null,
"usePreaggregatedTableTransforms": null,
"useWebAnalyticsPreAggregatedTables": null
},
"query_status": {
"complete": false,
"dashboard_id": null,
"end_time": null,
"error": false,
"error_message": null,
"expiration_time": null,
"id": "string",
"insight_id": null,
"labels": null,
"pickup_time": null,
"query_async": true,
"query_progress": {
"active_cpu_time": 0,
"bytes_read": 0,
"estimated_rows_total": 0,
"rows_read": 0,
"time_elapsed": 0
},
"results": null,
"start_time": null,
"task_id": null,
"team_id": 0
},
"resolved_date_range": {
"date_from": "2019-08-24T14:15:22Z",
"date_to": "2019-08-24T14:15:22Z"
},
"results": [
{}
],
"timings": null
},
"samplingFactor": null,
"series": [
{
"custom_name": null,
"fixedProperties": null,
"kind": "GroupNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"math_property_type": null,
"name": null,
"nodes": [
{
"custom_name": null,
"event": null,
"fixedProperties": null,
"kind": "EventsNode",
"limit": null,
"math": null,
"math_group_type_index": 0,
"math_hogql": null,
"math_multiplier": null,
"math_property": null,
"math_property_revenue_currency": {
"property": null,
"static": "AED"
},
"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": {
"name": null,
"productKey": null,
"scene": null
},
"trendsFilter": {
"aggregationAxisFormat": "numeric",
"aggregationAxisPostfix": null,
"aggregationAxisPrefix": null,
"breakdown_histogram_bin_count": null,
"confidenceLevel": null,
"decimalPlaces": null,
"detailedResultsAggregationType": "total",
"display": "Auto",
"excludeBoxPlotOutliers": true,
"formula": null,
"formulaNodes": null,
"formulas": null,
"goalLines": null,
"hiddenLegendIndexes": null,
"hideWeekends": false,
"minDecimalPlaces": null,
"movingAverageIntervals": null,
"resultCustomizationBy": "value",
"resultCustomizations": null,
"showAlertThresholdLines": false,
"showConfidenceIntervals": null,
"showLabelsOnSeries": null,
"showLegend": false,
"showMovingAverage": null,
"showMultipleYAxes": false,
"showPercentStackView": false,
"showTrendLines": null,
"showValuesOnSeries": false,
"smoothingIntervals": 1,
"yAxisScaleType": "log10"
},
"version": null
},
"suppressSessionAnalysisWarning": null,
"version": null,
"vizSpecificOptions": {
"ActionsPie": {
"disableHoverOffset": null,
"hideAggregation": null
},
"RETENTION": {
"hideLineGraph": null,
"hideSizeColumn": null,
"useSmallLayout": 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": {
"property1": null,
"property2": null
},
"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": {
"property1": null,
"property2": null
},
"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

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

  • environment_id
    string
  • 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 retrieve

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

activity_log:read

Path parameters

  • environment_id
    string
  • id
    integer

Query parameters

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

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 No response body

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

  • environment_id
    string
  • 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

  • environment_id
    string
  • 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

  • environment_id
    string
  • id
    integer

Query parameters

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

Request parameters

  • name
    string
  • derived_name
    string
  • query
  • order
    integer
  • deleted
    boolean
  • dashboards
    array
  • description
    string
  • 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"

Example response

Status 200 No response body

Retrieve environments insights activity

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

activity_log:read

Path parameters

  • environment_id
    string

Query parameters

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

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 No response body

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.

Path parameters

  • environment_id
    string

Query parameters

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

Request parameters

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

Example request

POST /api/environments/:environment_id/insights/cancel
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/cancel/\
-d name="string"

Example response

Status 200 No response body
Next page →

Community questions

Questions about this page? or post a community question.