Environments-16
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
Update environments plugin configs rearrange
Path parameters
- project_idstring
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
- plugininteger
- enabledboolean
- orderinteger
- namestring
- descriptionstring
- deletedboolean
Request
PATCH
/api /environments /:project_id /plugin_configs /rearrange
export POSTHOG_PERSONAL_API_KEY=[your personal api key]curl -X PATCH \-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \<ph_app_host>/api/environments/:project_id/plugin_configs/rearrange/\-d plugin="integer"
Response
Status 200 No response body
Update environments plugin configs rearrange
Path parameters
- project_idstring
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
- plugininteger
- enabledboolean
- orderinteger
- namestring
- descriptionstring
- deletedboolean
Request
PATCH
/api /environments /:project_id /plugin_configs /rearrange
export POSTHOG_PERSONAL_API_KEY=[your personal api key]curl -X PATCH \-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \<ph_app_host>/api/environments/:project_id/plugin_configs/rearrange/\-d plugin="integer"
Response
Status 200 No response body
Create environments query
Required API key scopes
query:read
Path parameters
- project_idstring
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.
- refreshDefault:
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 thequery_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
{}
Create environments query
Required API key scopes
query:read
Path parameters
- project_idstring
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.
- refreshDefault:
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 thequery_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
{}
Retrieve environments query
(Experimental)
Required API key scopes
query:read
Path parameters
- idstring
- project_idstring
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
{"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
- idstring
- project_idstring
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
{"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
- idstring
- project_idstring
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
- idstring
- project_idstring
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_idstring
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_idstring
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
Retrieve environments query draft sql
Path parameters
- project_idstring
Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
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/
Response
Status 200 No response body
Retrieve environments query draft sql
Path parameters
- project_idstring
Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
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/
Response
Status 200 No response body
List all environments session recordings
Required API key scopes
session_recording:read
Path parameters
- project_idstring
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
- limitinteger
Number of results to return per page.
- offsetinteger
The initial index from which to return the results.
Response
Request
GET
/api /environments /:project_id /session_recordings
export POSTHOG_PERSONAL_API_KEY=[your personal api key]curl \-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \<ph_app_host>/api/environments/:project_id/session_recordings/
Response
Status 200
{"count": 123,"next": "http://api.example.org/accounts/?offset=400&limit=100","previous": "http://api.example.org/accounts/?offset=200&limit=100","results": [{"id": "string","distinct_id": "string","viewed": true,"recording_duration": 0,"active_seconds": 0,"inactive_seconds": 0,"start_time": "2019-08-24T14:15:22Z","end_time": "2019-08-24T14:15:22Z","click_count": 0,"keypress_count": 0,"mouse_activity_count": 0,"console_log_count": 0,"console_warn_count": 0,"console_error_count": 0,"start_url": "string","person": {"id": 0,"name": "string","distinct_ids": "string","properties": null,"created_at": "2019-08-24T14:15:22Z","uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"},"storage": "string","snapshot_source": "string","ongoing": true,"activity_score": 0}]}
List all environments session recordings
Required API key scopes
session_recording:read
Path parameters
- project_idstring
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
- limitinteger
Number of results to return per page.
- offsetinteger
The initial index from which to return the results.
Response
Request
GET
/api /environments /:project_id /session_recordings
export POSTHOG_PERSONAL_API_KEY=[your personal api key]curl \-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \<ph_app_host>/api/environments/:project_id/session_recordings/
Response
Status 200
{"count": 123,"next": "http://api.example.org/accounts/?offset=400&limit=100","previous": "http://api.example.org/accounts/?offset=200&limit=100","results": [{"id": "string","distinct_id": "string","viewed": true,"recording_duration": 0,"active_seconds": 0,"inactive_seconds": 0,"start_time": "2019-08-24T14:15:22Z","end_time": "2019-08-24T14:15:22Z","click_count": 0,"keypress_count": 0,"mouse_activity_count": 0,"console_log_count": 0,"console_warn_count": 0,"console_error_count": 0,"start_url": "string","person": {"id": 0,"name": "string","distinct_ids": "string","properties": null,"created_at": "2019-08-24T14:15:22Z","uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"},"storage": "string","snapshot_source": "string","ongoing": true,"activity_score": 0}]}
Retrieve environments session recordings
Required API key scopes
session_recording:read
Path parameters
- idstring
A UUID string identifying this session recording.
- project_idstring
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 /session_recordings /: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/session_recordings/:id/
Response
Status 200
{"id": "string","distinct_id": "string","viewed": true,"recording_duration": 0,"active_seconds": 0,"inactive_seconds": 0,"start_time": "2019-08-24T14:15:22Z","end_time": "2019-08-24T14:15:22Z","click_count": 0,"keypress_count": 0,"mouse_activity_count": 0,"console_log_count": 0,"console_warn_count": 0,"console_error_count": 0,"start_url": "string","person": {"id": 0,"name": "string","distinct_ids": "string","properties": null,"created_at": "2019-08-24T14:15:22Z","uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"},"storage": "string","snapshot_source": "string","ongoing": true,"activity_score": 0}
Retrieve environments session recordings
Required API key scopes
session_recording:read
Path parameters
- idstring
A UUID string identifying this session recording.
- project_idstring
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 /session_recordings /: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/session_recordings/:id/
Response
Status 200
{"id": "string","distinct_id": "string","viewed": true,"recording_duration": 0,"active_seconds": 0,"inactive_seconds": 0,"start_time": "2019-08-24T14:15:22Z","end_time": "2019-08-24T14:15:22Z","click_count": 0,"keypress_count": 0,"mouse_activity_count": 0,"console_log_count": 0,"console_warn_count": 0,"console_error_count": 0,"start_url": "string","person": {"id": 0,"name": "string","distinct_ids": "string","properties": null,"created_at": "2019-08-24T14:15:22Z","uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"},"storage": "string","snapshot_source": "string","ongoing": true,"activity_score": 0}
Update environments session recordings
Required API key scopes
session_recording:write
Path parameters
- idstring
A UUID string identifying this session recording.
- project_idstring
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
- person
Response
Request
PATCH
/api /environments /:project_id /session_recordings /: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/:project_id/session_recordings/:id/\-d distinct_id="string"
Response
Status 200
{"id": "string","distinct_id": "string","viewed": true,"recording_duration": 0,"active_seconds": 0,"inactive_seconds": 0,"start_time": "2019-08-24T14:15:22Z","end_time": "2019-08-24T14:15:22Z","click_count": 0,"keypress_count": 0,"mouse_activity_count": 0,"console_log_count": 0,"console_warn_count": 0,"console_error_count": 0,"start_url": "string","person": {"id": 0,"name": "string","distinct_ids": "string","properties": null,"created_at": "2019-08-24T14:15:22Z","uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"},"storage": "string","snapshot_source": "string","ongoing": true,"activity_score": 0}
Update environments session recordings
Required API key scopes
session_recording:write
Path parameters
- idstring
A UUID string identifying this session recording.
- project_idstring
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
- person
Response
Request
PATCH
/api /environments /:project_id /session_recordings /: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/:project_id/session_recordings/:id/\-d distinct_id="string"
Response
Status 200
{"id": "string","distinct_id": "string","viewed": true,"recording_duration": 0,"active_seconds": 0,"inactive_seconds": 0,"start_time": "2019-08-24T14:15:22Z","end_time": "2019-08-24T14:15:22Z","click_count": 0,"keypress_count": 0,"mouse_activity_count": 0,"console_log_count": 0,"console_warn_count": 0,"console_error_count": 0,"start_url": "string","person": {"id": 0,"name": "string","distinct_ids": "string","properties": null,"created_at": "2019-08-24T14:15:22Z","uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"},"storage": "string","snapshot_source": "string","ongoing": true,"activity_score": 0}