External Data

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

Endpoints

POST
POST
GET
POST
POST
PATCH
POST
POST
GET
POST
GET
GET
POST
POST
POST
POST
GET
GET

Create external data sources disable cdc

Disable CDC on an existing source.

Cancels any running CDC extraction workflow, deletes the extraction schedule, delegates engine-side teardown to the source's adapter (drops slot/publication for Postgres; equivalent for other engines), clears cdc_* keys from job_inputs, soft-deletes companion CDC tables, and sets all CDC schemas to sync_type=None, should_sync=False so the user must pick a new sync strategy before they resume.

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/disable_cdc
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/disable_cdc/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Create external data sources enable cdc

Enable CDC on an existing source.

Provisions engine-side CDC resources via the source's adapter, writes the CDC config into source.job_inputs, and ensures the CDC extraction schedule exists. Re-runs prereq checks server-side so we never trust a stale client-side check.

Body params: cdc_management_mode ("posthog" | "self_managed"), plus engine-specific identifier hints (e.g. cdc_slot_name, cdc_publication_name for Postgres). Universal tuning fields: cdc_auto_drop_slot (optional bool), cdc_lag_warning_threshold_mb (optional int), cdc_lag_critical_threshold_mb (optional int).

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/enable_cdc
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/enable_cdc/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Retrieve external data sources jobs

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:read

Path parameters

  • id
    string

Example request

GET /api/projects/:project_id/external_data_sources/:id/jobs
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/jobs/

Example response

Status 200 No response body

Create external data sources refresh schemas

Fetch current schema/table list from the source and create any new ExternalDataSchema rows (no data sync).

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/refresh_schemas
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/refresh_schemas/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Create external data sources reload

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/reload
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/reload/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Update external data sources revenue analytics config

Update the revenue analytics configuration and return the full external data source.

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

PATCH /api/projects/:project_id/external_data_sources/:id/revenue_analytics_config
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/revenue_analytics_config/\
-d created_at="string"

Example response

Status 200 No response body

Create external data sources update cdc settings

Update CDC tuning fields without enabling/disabling.

Lets users edit cdc_auto_drop_slot, cdc_lag_warning_threshold_mb, and cdc_lag_critical_threshold_mb independently. These fields are universal across engines. Engine-specific identifiers (slot name, management mode, …) are immutable post-enable — switching them requires disable + enable.

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/update_cdc_settings
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/update_cdc_settings/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

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

Example request

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

Example response

Status 200 No response body

Retrieve 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/projects/:project_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/projects/:project_id/external_data_sources/:id/webhook_info/

Example response

Status 200 No response body

Create 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/projects/:project_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/projects/:project_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 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/projects/:project_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/projects/:project_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 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/projects/:project_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/projects/:project_id/external_data_sources/database_schema/\
-d source_type=undefined

Example response

Status 200 No response body

Create 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/projects/:project_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/projects/:project_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 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/projects/:project_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/projects/:project_id/external_data_sources/source_prefix/\
-d client_secret="string",\
-d account_id="string"

Example response

Status 200 No response body

Create 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/projects/:project_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/projects/:project_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 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/projects/:project_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/projects/:project_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 external data sources wizard

Create, Read, Update and Delete External data Sources.

Required API key scopes

external_data_source:read

Example request

GET /api/projects/:project_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/projects/:project_id/external_data_sources/wizard/

Example response

Status 200 No response body

Community questions

Questions about this page? or post a community question.