Environments-22

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

Endpoints

POST
GET
GET
GET
GET
POST
GET
DELETE
GET
POST
GET
POST

Create environments persons reset person distinct id

Required API key scopes

person:write

Path parameters

  • project_id
    string

Query parameters

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

Request parameters

  • properties

Example request

POST /api/environments/:project_id/persons/reset_person_distinct_id
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/:project_id/persons/reset_person_distinct_id/\
-d name="string"

Example response

Status 200 No response body

Retrieve environments persons stickiness

This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the capture API, the $set and $unset properties, or one of our SDKs.

Path parameters

  • project_id
    string

Query parameters

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

Example request

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

Example response

Status 200 No response body


Retrieve environments persons values

This endpoint is meant for reading and deleting persons. To create or update persons, we recommend using the capture API, the $set and $unset properties, or one of our SDKs.

Required API key scopes

person:read

Path parameters

  • project_id
    string

Query parameters

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

Example request

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

Example response

Status 200 No response body

List all environments plugin configs logs

Required API key scopes

plugin:read

Path parameters

  • plugin_config_id
    string
  • project_id
    string

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

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": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"plugin_id": 0,
"plugin_config_id": 0,
"timestamp": "2019-08-24T14:15:22Z",
"source": "SYSTEM",
"type": "DEBUG",
"message": "string",
"instance_id": "06587974-2dbe-4e10-8bf9-38cce0f5a366"
}
]
}

List all environments plugin configs logs

Required API key scopes

plugin:read

Path parameters

  • plugin_config_id
    string
  • project_id
    string

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

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": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"team_id": 0,
"plugin_id": 0,
"plugin_config_id": 0,
"timestamp": "2019-08-24T14:15:22Z",
"source": "SYSTEM",
"type": "DEBUG",
"message": "string",
"instance_id": "06587974-2dbe-4e10-8bf9-38cce0f5a366"
}
]
}

Create environments query

Required API key scopes

query:read

Path parameters

  • project_id
    string

Request parameters

  • async
    boolean
  • client_query_id
    string
  • filters_override
  • name
    string
  • query
  • refresh
    Default: blocking
  • variables_override
    object

Response


Example request

POST /api/environments/:project_id/query
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/:project_id/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{}

Create environments query

Required API key scopes

query:read

Path parameters

  • project_id
    string

Request parameters

  • async
    boolean
  • client_query_id
    string
  • filters_override
  • name
    string
  • query
  • refresh
    Default: blocking
  • variables_override
    object

Response


Example request

POST /api/environments/:project_id/query
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/:project_id/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{}

Retrieve environments query

(Experimental)

Required API key scopes

query:read

Path parameters

  • id
    string
  • project_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"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
}
}

Retrieve environments query

(Experimental)

Required API key scopes

query:read

Path parameters

  • id
    string
  • project_id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"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
}
}

Delete environments query

(Experimental)

Required API key scopes

query:read

Path parameters

  • id
    string
  • project_id
    string

Example request

DELETE /api/environments/:project_id/query/: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/:project_id/query/:id/

Example response

Status 204 Query cancelled

Delete environments query

(Experimental)

Required API key scopes

query:read

Path parameters

  • id
    string
  • project_id
    string

Example request

DELETE /api/environments/:project_id/query/: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/:project_id/query/:id/

Example response

Status 204 Query cancelled

Retrieve environments query log

Get query log details from query_log_archive table for a specific query_id, the query must have been issued in last 24 hours.

Path parameters

  • id
    string
  • project_id
    string

Example request

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

Example response

Status 200

Retrieve environments query log

Get query log details from query_log_archive table for a specific query_id, the query must have been issued in last 24 hours.

Path parameters

  • id
    string
  • project_id
    string

Example request

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

Example response

Status 200

Create environments query check auth for async

Path parameters

  • project_id
    string

Example request

POST /api/environments/:project_id/query/check_auth_for_async
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/:project_id/query/check_auth_for_async/

Example response

Status 200 No response body

Create environments query check auth for async

Path parameters

  • project_id
    string

Example request

POST /api/environments/:project_id/query/check_auth_for_async
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/:project_id/query/check_auth_for_async/

Example response

Status 200 No response body

Retrieve environments query draft sql

Path parameters

  • project_id
    string

Example request

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

Example response

Status 200 No response body

Retrieve environments query draft sql

Path parameters

  • project_id
    string

Example request

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

Example response

Status 200 No response body

Create environments query upgrade

Upgrades a query without executing it. Returns a query with all nodes migrated to the latest version.

Path parameters

  • project_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:project_id/query/upgrade
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/:project_id/query/upgrade/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"query": {
"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
}
}

Create environments query upgrade

Upgrades a query without executing it. Returns a query with all nodes migrated to the latest version.

Path parameters

  • project_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:project_id/query/upgrade
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/:project_id/query/upgrade/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"query": {
"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
}
}
Next page →

Community questions

Questions about this page? or post a community question.