Environments-10

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

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.

Retrieve environments persons path

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

Request

GET /api/environments/:project_id/persons/path
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/path/

Response

Status 200 No response body

Retrieve environments persons path

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

Request

GET /api/environments/:project_id/persons/path
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/path/

Response

Status 200 No response body

Create environments persons path

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

Request parameters

  • properties

Request

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

Response

Status 200 No response body

Create environments persons path

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

Request parameters

  • properties

Request

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

Response

Status 200 No response body

Retrieve environments persons retention

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

Request

GET /api/environments/:project_id/persons/retention
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/retention/

Response

Status 200 No response body

Retrieve environments persons retention

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

Request

GET /api/environments/:project_id/persons/retention
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/retention/

Response

Status 200 No response body

Retrieve environments persons stickiness

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

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/

Response

Status 200 No response body

Retrieve environments persons stickiness

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

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/

Response

Status 200 No response body

Retrieve environments persons values

Required API key scopes

person:read

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

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/

Response

Status 200 No response body

Retrieve environments persons values

Required API key scopes

person:read

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Query parameters

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

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/

Response

Status 200 No response body

Create environments query

Required API key scopes

query:read

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request parameters

  • async
  • client_query_id

    Client provided query ID. Can be used to retrieve the status or cancel the query.

  • filters_override
  • query

    Submit a JSON string representing a query for PostHog data analysis, for example a HogQL query.

    Example payload:

    
    {"query": {"kind": "HogQLQuery", "query": "select * from events limit 100"}}
    
    

    For more details on HogQL queries, see the PostHog HogQL documentation.

  • refresh
    Default: blocking

    Whether results should be calculated sync or async, and how much to rely on the cache:

    • 'blocking' - calculate synchronously (returning only when the query is done), UNLESS there are very fresh results in the cache
    • 'async' - kick off background calculation (returning immediately with a query status), UNLESS there are very fresh results in the cache
    • 'lazy_async' - kick off background calculation, UNLESS there are somewhat fresh results in the cache
    • 'force_blocking' - calculate synchronously, even if fresh results are already cached
    • 'force_async' - kick off background calculation, even if fresh results are already cached
    • 'force_cache' - return cached data or a cache miss; always completes immediately as it never calculates Background calculation can be tracked using the query_status response field.
  • variables_override

Response


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

Response

Status 200
RESPONSE
{}

Create environments query

Required API key scopes

query:read

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request parameters

  • async
  • client_query_id

    Client provided query ID. Can be used to retrieve the status or cancel the query.

  • filters_override
  • query

    Submit a JSON string representing a query for PostHog data analysis, for example a HogQL query.

    Example payload:

    
    {"query": {"kind": "HogQLQuery", "query": "select * from events limit 100"}}
    
    

    For more details on HogQL queries, see the PostHog HogQL documentation.

  • refresh
    Default: blocking

    Whether results should be calculated sync or async, and how much to rely on the cache:

    • 'blocking' - calculate synchronously (returning only when the query is done), UNLESS there are very fresh results in the cache
    • 'async' - kick off background calculation (returning immediately with a query status), UNLESS there are very fresh results in the cache
    • 'lazy_async' - kick off background calculation, UNLESS there are somewhat fresh results in the cache
    • 'force_blocking' - calculate synchronously, even if fresh results are already cached
    • 'force_async' - kick off background calculation, even if fresh results are already cached
    • 'force_cache' - return cached data or a cache miss; always completes immediately as it never calculates Background calculation can be tracked using the query_status response field.
  • variables_override

Response


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

Response

Status 200
RESPONSE
{}

Retrieve environments query

(Experimental)

Required API key scopes

query:read

Path parameters

  • id
    string
  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Response


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/

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": null,
"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

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Response


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/

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": null,
"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

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

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/

Response

Status 204 Query cancelled

Delete environments query

(Experimental)

Required API key scopes

query:read

Path parameters

  • id
    string
  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

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/

Response

Status 204 Query cancelled

Create environments query chat

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request

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

Response

Status 200 No response body

Create environments query chat

Path parameters

  • project_id
    string

    Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request

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

Response

Status 200 No response body
Next page →

Questions?

Was this page useful?