Data

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

Endpoints

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

Create environments external data sources update webhook inputs

Also available via the PostHog MCP server:

  • external-data-sources-update-webhook-inputs-createUpdate webhook inputs (signing secret, etc.)

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:write

Path parameters

  • id
    string

Request parameters

  • created_via
  • client_secret
    string
  • account_id
    string
  • prefix
    stringnull
  • description
    stringnull
  • job_inputs

Example request

POST /api/environments/:environment_id/external_data_sources/:id/update_webhook_inputs
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/external_data_sources/:id/update_webhook_inputs/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Retrieve environments external data sources webhook info

Also available via the PostHog MCP server:

  • external-data-sources-webhook-info-retrieveGet webhook status for a source

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:read

Path parameters

  • id
    string

Example request

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

Example response

Status 200 No response body

Create environments external data sources check cdc prerequisites

Also available via the PostHog MCP server:

  • external-data-sources-check-cdc-prerequisites-createCheck Postgres CDC prerequisites

Validate CDC prerequisites against a live Postgres connection.

Used by the source wizard to surface ✅/❌ checks before source creation, and by the self-managed setup popup to verify user-created publications.

Required API key scopes

external_data_source:write

Example request

POST /api/environments/:environment_id/external_data_sources/check_cdc_prerequisites
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/external_data_sources/check_cdc_prerequisites/

Example response

Status 200 Whether the Postgres database satisfies CDC prerequisites.
Status 400 Invalid config, disallowed host, or connection failure.

List all environments external data sources connections

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:read

Query parameters

  • limit
    integer
  • offset
    integer
  • search
    string

Response


Example request

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

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",
"prefix": "string",
"engine": "duckdb"
}
]
}

Create environments external data sources database schema

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:write

Request parameters

  • source_type

Example request

POST /api/environments/:environment_id/external_data_sources/database_schema
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/external_data_sources/database_schema/\
-d source_type=undefined

Example response

Status 200 No response body

Create environments external data sources source prefix

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:write

Request parameters

  • created_via
  • client_secret
    string
  • account_id
    string
  • prefix
    stringnull
  • description
    stringnull
  • job_inputs

Example request

POST /api/environments/:environment_id/external_data_sources/source_prefix
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/external_data_sources/source_prefix/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Retrieve environments external data sources wizard

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:read

Example request

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

Example response

Status 200 No response body

List all environments insight variables

Required API key scopes

insight_variable:read

Query parameters

  • page
    integer

Response


Example request

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

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?page=4",
"previous": "http://api.example.org/accounts/?page=2",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"type": "String",
"default_value": null,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"code_name": "string",
"values": null
}
]
}

Create environments insight variables

Required API key scopes

insight_variable:write

Request parameters

  • name
    string
  • type
  • default_value
  • values

Response


Example request

POST /api/environments/:environment_id/insight_variables
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/insight_variables/\
-d name="string",\
-d type=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"type": "String",
"default_value": null,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"code_name": "string",
"values": null
}

Retrieve environments insight variables

Required API key scopes

insight_variable:read

Path parameters

  • id
    string

Response


Example request

GET /api/environments/:environment_id/insight_variables/: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/insight_variables/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"type": "String",
"default_value": null,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"code_name": "string",
"values": null
}

Update environments insight variables

Required API key scopes

insight_variable:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • type
  • default_value
  • values

Response


Example request

PATCH /api/environments/:environment_id/insight_variables/: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/insight_variables/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"type": "String",
"default_value": null,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"code_name": "string",
"values": null
}

Delete environments insight variables

Required API key scopes

insight_variable:write

Path parameters

  • id
    string

Example request

DELETE /api/environments/:environment_id/insight_variables/: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/insight_variables/:id/

Example response

Status 204 No response body

List all environments warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:read

Query parameters

  • page
    integer
  • search
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?page=4",
"previous": "http://api.example.org/accounts/?page=2",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string"
}
]
}

Create environments warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Request parameters

  • deleted
    booleannull
  • name
    string
  • query
    object
  • folder_id
    stringnull
  • edited_history_id
    stringnull
  • soft_update
    booleannull
  • dag_id
    stringnull
  • is_test
    boolean

Response


Example request

POST /api/environments/:environment_id/warehouse_saved_queries
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/warehouse_saved_queries/\
-d name="string",\
-d query="object"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": 0,
"soft_update": true,
"dag_id": "42728853-0f3b-405e-82ac-865eb391bcdb",
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string"
}

Retrieve environments warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:read

Path parameters

  • id
    string

Response


Example request

GET /api/environments/:environment_id/warehouse_saved_queries/: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/warehouse_saved_queries/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": 0,
"soft_update": true,
"dag_id": "42728853-0f3b-405e-82ac-865eb391bcdb",
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string"
}

Update environments warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Request parameters

  • deleted
    booleannull
  • name
    string
  • query
    object
  • folder_id
    stringnull
  • edited_history_id
    stringnull
  • soft_update
    booleannull
  • dag_id
    stringnull
  • is_test
    boolean

Response


Example request

PATCH /api/environments/:environment_id/warehouse_saved_queries/: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/warehouse_saved_queries/:id/\
-d deleted=["boolean","null"]

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": 0,
"soft_update": true,
"dag_id": "42728853-0f3b-405e-82ac-865eb391bcdb",
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string"
}

Delete environments warehouse saved queries

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

warehouse_view:write

Path parameters

  • id
    string

Example request

DELETE /api/environments/:environment_id/warehouse_saved_queries/: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/warehouse_saved_queries/:id/

Example response

Status 204 No response body

Retrieve environments warehouse saved queries activity

Create, Read, Update and Delete Warehouse Tables.

Required API key scopes

activity_log:read

Path parameters

  • id
    string

Response


Example request

GET /api/environments/:environment_id/warehouse_saved_queries/: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/warehouse_saved_queries/:id/activity/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"deleted": true,
"name": "string",
"query": {
"kind": "HogQLQuery",
"query": "string"
},
"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"
},
"created_at": "2019-08-24T14:15:22Z",
"sync_frequency": "string",
"columns": [
{}
],
"status": "Cancelled",
"last_run_at": "2019-08-24T14:15:22Z",
"managed_viewset_kind": "string",
"folder_id": "7695bac3-9397-4ec2-9335-45a2a16f1901",
"folder_name": "string",
"latest_error": "string",
"edited_history_id": "string",
"latest_history_id": 0,
"soft_update": true,
"dag_id": "42728853-0f3b-405e-82ac-865eb391bcdb",
"is_materialized": true,
"origin": "data_warehouse",
"is_test": true,
"expires_at": "2019-08-24T14:15:22Z",
"user_access_level": "string"
}

Community questions

Questions about this page? or post a community question.