External Data

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

Endpoints

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

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 setup

One-shot data warehouse source setup.

Validate credentials, discover available tables, enable them all with sensible sync defaults (incremental where supported, else append, else full refresh), and create the source in a single call — the caller never has to assemble a schemas array. For sources that support webhooks (e.g. Stripe), a webhook is auto-registered after creation: on success webhook-capable tables switch to real-time webhook sync (unlocking webhook-only tables); on failure the polling defaults stay in place. For fine-grained table/sync control, use the lower-level database_schema + create flow instead.

Required API key scopes

external_data_source:write

Request parameters

  • source_type
  • payload
    object
  • prefix
    stringnull
  • description
    stringnull
  • direct_query_enabled
    boolean
    Default: true

Response


Example request

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

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"webhook": {
"success": true,
"webhook_url": "string",
"error": "string",
"pending_inputs": [
"string"
]
}
}

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
  • direct_query_enabled
    boolean
  • 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

Create environments external data sources store credentials

Validate and store credentials for a data warehouse source without creating the source.

Backs the source connect page: the user enters credentials directly in PostHog, they are checked against a live connection, then stashed encrypted in a temporary store. The returned credential id can be passed to setup as {'credential_id': <id>} to create the source — so secrets never travel through an agent conversation. The stash is single-use: it is deleted as soon as setup consumes it, and expires after 24 hours if never consumed.

Required API key scopes

external_data_source:write

Request parameters

  • source_type
  • payload
    object

Response


Example request

POST /api/environments/:environment_id/external_data_sources/store_credentials
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/store_credentials/\
-d source_type=undefined,\
-d payload="object"

Example response

Status 201
RESPONSE
{
"credential_id": "13c40afa-2996-4a0c-b2e9-68fba9462242",
"source_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"expires_at": "2019-08-24T14:15:22Z"
}

List all environments external data sources stored credentials

List credentials stored via the source connect page that haven't been consumed yet.

Returns metadata only (id, source type, timestamps) — never the secrets themselves. Stored credentials are temporary: they disappear once consumed by setup or when they expire. Newest first, so after a user confirms they've finished the connect page, the first entry for the source type is the one to pass to setup.

Required API key scopes

external_data_source:read

Query parameters

  • search
    string
  • source_type
    string

Example request

GET /api/environments/:environment_id/external_data_sources/stored_credentials
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/stored_credentials/

Example response

Status 200
RESPONSE
{
"credential_id": "13c40afa-2996-4a0c-b2e9-68fba9462242",
"source_type": "string",
"created_at": "2019-08-24T14:15:22Z",
"expires_at": "2019-08-24T14:15:22Z"
}

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 external data sources

Also available via the PostHog MCP server:

  • external-data-sources-listList data warehouse sources

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/projects/:project_id/external_data_sources
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/external_data_sources/

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",
"created_at": "2019-08-24T14:15:22Z",
"created_by": "string",
"created_via": "web",
"status": "string",
"client_secret": "string",
"account_id": "string",
"source_type": "Ashby",
"latest_error": "string",
"prefix": "string",
"description": "string",
"access_method": "warehouse",
"direct_query_enabled": true,
"engine": "duckdb",
"last_run_at": "string",
"schemas": [
{}
],
"job_inputs": null,
"revenue_analytics_config": {
"enabled": true,
"include_invoiceless_charges": true
},
"user_access_level": "string",
"supports_webhooks": true,
"supports_column_selection": true
}
]
}

Create external data sources

Also available via the PostHog MCP server:

  • external-data-sources-createCreate data warehouse source (advanced; prefer source setup)

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:write

Request parameters

  • source_type
  • payload
    object
  • prefix
    stringnull
  • description
    stringnull
  • access_method
    Default: warehouse
  • created_via
    Default: api
  • direct_query_enabled
    boolean
    Default: true

Response


Example request

POST /api/projects/:project_id/external_data_sources
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/projects/:project_id/external_data_sources/\
-d source_type=undefined,\
-d payload="object"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"created_at": "2019-08-24T14:15:22Z",
"created_by": "string",
"created_via": "web",
"status": "string",
"client_secret": "string",
"account_id": "string",
"source_type": "Ashby",
"latest_error": "string",
"prefix": "string",
"description": "string",
"access_method": "warehouse",
"direct_query_enabled": true,
"engine": "duckdb",
"last_run_at": "string",
"schemas": [
{}
],
"job_inputs": null,
"revenue_analytics_config": {
"enabled": true,
"include_invoiceless_charges": true
},
"user_access_level": "string",
"supports_webhooks": true,
"supports_column_selection": true
}

Retrieve external data sources

Also available via the PostHog MCP server:

  • external-data-sources-retrieveGet data warehouse source

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:read

Path parameters

  • id
    string

Response


Example request

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

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"created_at": "2019-08-24T14:15:22Z",
"created_by": "string",
"created_via": "web",
"status": "string",
"client_secret": "string",
"account_id": "string",
"source_type": "Ashby",
"latest_error": "string",
"prefix": "string",
"description": "string",
"access_method": "warehouse",
"direct_query_enabled": true,
"engine": "duckdb",
"last_run_at": "string",
"schemas": [
{}
],
"job_inputs": null,
"revenue_analytics_config": {
"enabled": true,
"include_invoiceless_charges": true
},
"user_access_level": "string",
"supports_webhooks": true,
"supports_column_selection": true
}

Update external data sources

Also available via the PostHog MCP server:

  • external-data-sources-partial-updateUpdate data warehouse source

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
  • direct_query_enabled
    boolean
  • job_inputs

Response


Example request

PATCH /api/projects/:project_id/external_data_sources/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/external_data_sources/:id/\
-d created_at="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"created_at": "2019-08-24T14:15:22Z",
"created_by": "string",
"created_via": "web",
"status": "string",
"client_secret": "string",
"account_id": "string",
"source_type": "Ashby",
"latest_error": "string",
"prefix": "string",
"description": "string",
"access_method": "warehouse",
"direct_query_enabled": true,
"engine": "duckdb",
"last_run_at": "string",
"schemas": [
{}
],
"job_inputs": null,
"revenue_analytics_config": {
"enabled": true,
"include_invoiceless_charges": true
},
"user_access_level": "string",
"supports_webhooks": true,
"supports_column_selection": true
}

Delete external data sources

Also available via the PostHog MCP server:

  • external-data-sources-destroyDelete data warehouse source

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/external_data_sources/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/external_data_sources/:id/

Example response

Status 204 No response body

Update external data sources bulk update schemas

Create, Read, Update and Delete External data Sources.

Path parameters

  • id
    string

Query parameters

  • limit
    integer
  • offset
    integer
  • search
    string

Request parameters

  • schemas
    Click to open
    array

Response


Example request

PATCH /api/projects/:project_id/external_data_sources/:id/bulk_update_schemas
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/external_data_sources/:id/bulk_update_schemas/\
-d schemas="array"

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",
"name": "string",
"label": "string",
"table": {},
"should_sync": true,
"last_synced_at": "2019-08-24T14:15:22Z",
"latest_error": "string",
"incremental": true,
"status": "string",
"sync_type": "full_refresh",
"incremental_field": "string",
"incremental_field_type": "integer",
"incremental_field_lookback_seconds": 5184000,
"sync_frequency": "never",
"sync_time_of_day": "14:15:22Z",
"description": "string",
"primary_key_columns": [
"string"
],
"cdc_table_mode": "consolidated",
"enabled_columns": [
"string"
],
"row_filters": [
{
"column": "string",
"operator": "string",
"value": null
}
],
"available_columns": [
{
"name": "string",
"data_type": "string",
"is_nullable": true
}
],
"source": {
"id": "string",
"source_type": "string",
"supports_column_selection": true,
"user_access_level": "string"
}
}
]
}

Retrieve external data sources cdc status

Live CDC health for an existing source: slot/publication existence and WAL lag.

Reads from the source DB via the engine adapter. Returns {"enabled": false} when CDC is off, or the stored config plus live slot_exists / publication_exists / lag_bytes when on. 400s if the source DB is unreachable so the UI can show a degraded/unreachable state.

Required API key scopes

external_data_source:read

Path parameters

  • id
    string

Example request

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

Example response

Status 200 No response body

Create external data sources check cdc prerequisites for source

Validate CDC prerequisites for an existing source using its stored credentials.

The detail=False check_cdc_prerequisites action is for the creation wizard, where the client still holds the raw connection config (incl. password) in the form. On the Configuration page the source already exists and secret fields are stripped from API responses — so the client can't supply them. This reads the stored (encrypted) credentials from the DB via the adapter instead.

Body params: cdc_management_mode ("posthog" | "self_managed"), cdc_slot_name (optional), cdc_publication_name (optional).

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
  • direct_query_enabled
    boolean
  • job_inputs

Example request

POST /api/projects/:project_id/external_data_sources/:id/check_cdc_prerequisites_for_source
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/projects/:project_id/external_data_sources/:id/check_cdc_prerequisites_for_source/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Create external data sources create webhook

Also available via the PostHog MCP server:

  • external-data-sources-create-webhook-createCreate and register a webhook for a source

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
  • direct_query_enabled
    boolean
  • job_inputs

Example request

POST /api/projects/:project_id/external_data_sources/:id/create_webhook
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/projects/:project_id/external_data_sources/:id/create_webhook/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Create external data sources delete webhook

Also available via the PostHog MCP server:

  • external-data-sources-delete-webhook-createDelete a source's webhook

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
  • direct_query_enabled
    boolean
  • job_inputs

Example request

POST /api/projects/:project_id/external_data_sources/:id/delete_webhook
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/projects/:project_id/external_data_sources/:id/delete_webhook/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Community questions

Questions about this page? or post a community question.