:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(batch-exports): PostgreSQL frontend integration (#62173)
Tomás Farías Santana4bedcde4d575
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex d24645d27d4c..b4991397aa7a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -4577,9 +4577,9 @@ snapshots:scenes-app-batchexports--new-http-export--light:hash: v1.k794b7964.57a9e794717b31d1d38c525bb94ccb83146dec6e5132b687b4d37b187dcc5f50.pPRfr3IHa9In8YGfVfqcW6W8Ia2hVO2D8snx_2Qgo20scenes-app-batchexports--new-postgres-export--dark:- hash: v1.k794b7964.6edf090d1ebd7d5457b60cac591cd4e3479fe5b0f26111a90665cfab6da8b787.F24aRAs1TCIrtG-0J03xBp7L4BdEHAZqthDa3_qf_yU+ hash: v1.k794b7964.8e1760701728ac462b0f6ceef80a1b9cdaf36a08bd482d460deaf3299c30a7ad.qDT0LSvX0DlJBr_JM7ma9ZMsYx8TVw0UY7urxDCGjboscenes-app-batchexports--new-postgres-export--light:- hash: v1.k794b7964.26f2cc2387acf287d0b6765d06859a7f9f1b4d0a825a02fe2992629f4d07cc8b.xXylSXY9SPOV2JJHWB7AyyS1cfvqVaJBeQNTXq-6K2g+ hash: v1.k794b7964.0304d23c0e2b65397b894a2264f4c62937d74792b70ae5f57e67bddc8b01ab66.Wi96xSFv5jA4ZSxgiW8_I_JoUAfaJUrQmets-lPY6lUscenes-app-batchexports--new-redshift-export--dark:hash: v1.k794b7964.769e74e5097c2e53ae958785fdb3e6833a683f700a589f03dd7635fb4b2e0787.o50DQ7asE_mTNQg0veJYD6akpaYCutsM_lZRQrKhU7oscenes-app-batchexports--new-redshift-export--light:diff --git a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsxindex cc531e80259c..cf94419c8d6a 100644--- a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx+++ b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx@@ -2,6 +2,7 @@ import { AzureBlobSetupModal } from 'scenes/integrations/azure-blob/AzureBlobSetimport { DatabricksSetupModal } from 'scenes/integrations/databricks/DatabricksSetupModal'import { GitLabSetupModal } from 'scenes/integrations/gitlab/GitLabSetupModal'import { GoogleCloudServiceAccountSetupModal } from 'scenes/integrations/google-cloud-service-account/GoogleCloudServiceAccountSetupModal'+import { PostgreSQLSetupModal } from 'scenes/integrations/postgresql/PostgreSQLSetupModal'import { urls } from 'scenes/urls'import { ChannelSetupModal } from 'products/workflows/frontend/Channels/ChannelSetupModal'@@ -55,6 +56,17 @@ registerIntegrationSetup({),})+registerIntegrationSetup({+ kind: 'postgresql',+ menuItem: ({ openModal }) => ({+ label: 'Configure new PostgreSQL connection',+ onClick: () => openModal('postgresql'),+ }),+ SetupModal: ({ isOpen, integration, onComplete }) => (+ <PostgreSQLSetupModal isOpen={isOpen} integration={integration} onComplete={onComplete} />+ ),+})+registerIntegrationSetup({kind: 'google-cloud-service-account',menuItem: ({ openModal }) => ({diff --git a/frontend/src/lib/integrations/utils.ts b/frontend/src/lib/integrations/utils.tsindex db2da70f995e..3e34b92238ff 100644--- a/frontend/src/lib/integrations/utils.ts+++ b/frontend/src/lib/integrations/utils.ts@@ -24,6 +24,7 @@ import IconLinkedIn from 'public/services/linkedin.png'import IconMailjet from 'public/services/mailjet.png'import IconMetaAds from 'public/services/meta-ads.png'import IconPinterest from 'public/services/pinterest_ads.png'+import IconPostgres from 'public/services/postgres.png'import IconReddit from 'public/services/reddit.png'import IconSalesforce from 'public/services/salesforce.png'import IconSlack from 'public/services/slack.png'@@ -67,6 +68,7 @@ export const ICONS: Record<IntegrationKind, any> = {'customerio-app': IconCustomerIO,'customerio-webhook': IconCustomerIO,'customerio-track': IconCustomerIO,+ postgresql: IconPostgres,}export const getIntegrationNameFromKind = (kind: string): string => {@@ -101,6 +103,8 @@ export const getIntegrationNameFromKind = (kind: string): string => {return 'GitHub'case 'firebase':return 'Firebase'+ case 'postgresql':+ return 'PostgreSQL'default:return capitalizeFirstLetter(kind)}diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 761d70b654a3..aebe34fa5f41 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -24885,7 +24885,8 @@"pinterest-ads","customerio-app","customerio-webhook",- "customerio-track"+ "customerio-track",+ "postgresql"],"type": "string"},diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.tsindex cf3cfbb21216..9be1cbe32c1a 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts@@ -450,7 +450,7 @@ describe('batchExportConfigFormLogic', () => {},{service: 'Postgres' as const,- fields: ['user', 'password', 'host', 'port', 'database', 'schema', 'table_name'],+ fields: ['integration_id', 'database', 'schema', 'table_name'],},{service: 'Redshift' as const,@@ -886,21 +886,15 @@ describe('batchExportConfigFormLogic', () => {name: 'Postgres',service: 'Postgres' as const,requiredValues: {- user: 'pg-user',- password: 'pg-pass',- host: 'pg-host',- port: 5432,+ integration_id: 13,database: 'pg-db',schema: 'public',table_name: 'events',},expectedDestination: {type: 'Postgres',+ integration: 13,config: {- user: 'pg-user',- password: 'pg-pass',- host: 'pg-host',- port: 5432,database: 'pg-db',schema: 'public',table_name: 'events',diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsxindex 8a9c32fa36d6..738c899b213e 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsx@@ -1,41 +1,56 @@import { IconInfo } from '@posthog/icons'import { LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'+import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'import type { DestinationDefinition } from './types'export const postgresDefinition: DestinationDefinition = {type: 'Postgres',+ // New Postgres exports must store credentials in a linked Integration. Exports created before+ // integrations existed keep their inline credentials (grandfathered), detected by integration_id.+ usesIntegration: true,defaults: () => ({}),- requiredFields: ({ isNew }) => [- ...(isNew ? ['user'] : []),- ...(isNew ? ['password'] : []),- 'host',- 'port',- 'database',- 'schema',- 'table_name',- ],+ requiredFields: ({ isNew, formValues }) => {+ if (isNew || formValues.integration_id) {+ // New exports must pick an integration; existing integration-backed exports keep theirs.+ return [...(isNew ? ['integration_id'] : []), 'database', 'schema', 'table_name']+ }+ // Legacy inline-credential exports keep their original fields when edited.+ return ['host', 'port', 'database', 'schema', 'table_name']+ },eventTableOverrides: { teamIdHogql: 'toInt32(team_id)' },- Fields: function PostgresFields({ isNew }) {+ Fields: function PostgresFields({ isNew, formValues }) {+ const useIntegration = isNew || !!formValues.integration_id+return (<>- <LemonField name="user" label="User">- <LemonInput placeholder={isNew ? 'my-user' : 'Leave unchanged'} />- </LemonField>+ {useIntegration ? (+ <LemonField name="integration_id" label="Connection">+ {({ value, onChange }) => (+ <IntegrationChoice integration="postgresql" value={value} onChange={onChange} />+ )}+ </LemonField>+ ) : (+ <>+ <LemonField name="user" label="User">+ <LemonInput placeholder={isNew ? 'my-user' : 'Leave unchanged'} />+ </LemonField>- <LemonField name="password" label="Password">- <LemonInput placeholder={isNew ? 'my-password' : 'Leave unchanged'} type="password" />- </LemonField>+ <LemonField name="password" label="Password">+ <LemonInput placeholder={isNew ? 'my-password' : 'Leave unchanged'} type="password" />+ </LemonField>- <LemonField name="host" label="Host">- <LemonInput placeholder="my-host" />- </LemonField>+ <LemonField name="host" label="Host">+ <LemonInput placeholder="my-host" />+ </LemonField>- <LemonField name="port" label="Port">- <LemonInput placeholder="5432" type="number" min="0" max="65535" />- </LemonField>+ <LemonField name="port" label="Port">+ <LemonInput placeholder="5432" type="number" min="0" max="65535" />+ </LemonField>+ </>+ )}<LemonField name="database" label="Database"><LemonInput placeholder="my-database" />@@ -49,23 +64,25 @@ export const postgresDefinition: DestinationDefinition = {<LemonInput placeholder="events" /></LemonField>- <LemonField name="has_self_signed_cert">- {({ value, onChange }) => (- <LemonCheckbox- bordered- label={- <span className="flex gap-2 items-center">- Does your Postgres instance have a self-signed SSL certificate?- <Tooltip title="In most cases, Heroku and RDS users should check this.">- <IconInfo className="text-lg text-secondary" />- </Tooltip>- </span>- }- checked={!!value}- onChange={onChange}- />- )}- </LemonField>+ {!useIntegration && (+ <LemonField name="has_self_signed_cert">+ {({ value, onChange }) => (+ <LemonCheckbox+ bordered+ label={+ <span className="flex gap-2 items-center">+ Does your Postgres instance have a self-signed SSL certificate?+ <Tooltip title="In most cases, Heroku and RDS users should check this.">+ <IconInfo className="text-lg text-secondary" />+ </Tooltip>+ </span>+ }+ checked={!!value}+ onChange={onChange}+ />+ )}+ </LemonField>+ )}</>)},diff --git a/frontend/src/scenes/integrations/postgresql/PostgreSQLSetupModal.tsx b/frontend/src/scenes/integrations/postgresql/PostgreSQLSetupModal.tsxnew file mode 100644index 000000000000..7efe980b044b--- /dev/null+++ b/frontend/src/scenes/integrations/postgresql/PostgreSQLSetupModal.tsx@@ -0,0 +1,125 @@+import { useActions, useValues } from 'kea'+import { Form } from 'kea-forms'++import { LemonButton, LemonCheckbox, LemonInput, LemonModal, LemonSelect, lemonToast } from '@posthog/lemon-ui'++import { LemonField } from 'lib/lemon-ui/LemonField'+import { LemonFileInput } from 'lib/lemon-ui/LemonFileInput/LemonFileInput'++import IconPostgres from 'public/services/postgres.png'++import { PostgreSQLSetupModalLogicProps, postgreSQLSetupModalLogic } from './postgreSQLSetupModalLogic'++export const PostgreSQLSetupModal = (props: PostgreSQLSetupModalLogicProps): JSX.Element => {+ const { postgreSQLIntegration, isPostgreSQLIntegrationSubmitting } = useValues(postgreSQLSetupModalLogic(props))+ const { submitPostgreSQLIntegration, setPostgreSQLIntegrationValue } = useActions(postgreSQLSetupModalLogic(props))++ return (+ <LemonModal+ isOpen={props.isOpen}+ title={+ <div className="flex items-center gap-2">+ <img src={IconPostgres} alt="PostgreSQL" className="w-6 h-6" />+ <span>Configure PostgreSQL integration</span>+ </div>+ }+ onClose={props.onComplete}+ >+ <Form logic={postgreSQLSetupModalLogic} props={props} formKey="postgreSQLIntegration">+ <div className="gap-4 flex flex-col">+ <LemonField name="host" label="Host">+ <LemonInput placeholder="my-host" />+ </LemonField>++ <LemonField name="port" label="Port">+ <LemonInput placeholder="5432" type="number" min="0" max="65535" />+ </LemonField>++ <LemonField name="user" label="User">+ <LemonInput placeholder="postgres" />+ </LemonField>++ <LemonField name="password" label="Password">+ <LemonInput type="password" />+ </LemonField>++ <LemonField+ name="ssl_mode"+ label="Verify server identity?"+ info={+ <>+ Verifies that the certificate presented by the database server is signed by a trusted+ certificate authority — and, optionally, that its hostname matches the host you entered.+ This guards against man-in-the-middle attacks.+ <br />+ <br />+ The connection is always encrypted regardless of this setting, because PostHog requires+ TLS. These options only add verification of the server certificate.+ </>+ }+ >+ <LemonSelect+ options={[+ { value: 'no', label: 'No' },+ { value: 'verify-ca', label: 'Verify certificate authority' },+ { value: 'verify-full', label: 'Verify certificate authority and server hostname' },+ ]}+ />+ </LemonField>++ {postgreSQLIntegration.ssl_mode !== 'no' && (+ <>+ <LemonField name="use_system_ca">+ {({ value, onChange }) => (+ <LemonCheckbox+ bordered+ checked={!!value}+ onChange={onChange}+ label="Use the system certificate authorities"+ />+ )}+ </LemonField>++ {!postgreSQLIntegration.use_system_ca && (+ <LemonField name="ssl_root_cert" label="Root certificate">+ {() => (+ <LemonFileInput+ accept=".crt,.pem,.cer,.ca-bundle"+ multiple={false}+ onChange={(files) => {+ if (files[0]) {+ void files[0]+ .text()+ .then((text) =>+ setPostgreSQLIntegrationValue('ssl_root_cert', text)+ )+ .catch(() => {+ lemonToast.error('Failed to read the certificate file')+ setPostgreSQLIntegrationValue('ssl_root_cert', null)+ })+ } else {+ setPostgreSQLIntegrationValue('ssl_root_cert', null)+ }+ }}+ />+ )}+ </LemonField>+ )}+ </>+ )}++ <div className="flex justify-end">+ <LemonButton+ type="primary"+ htmlType="submit"+ loading={isPostgreSQLIntegrationSubmitting}+ onClick={submitPostgreSQLIntegration}+ >+ Connect+ </LemonButton>+ </div>+ </div>+ </Form>+ </LemonModal>+ )+}diff --git a/frontend/src/scenes/integrations/postgresql/postgreSQLSetupModalLogic.ts b/frontend/src/scenes/integrations/postgresql/postgreSQLSetupModalLogic.tsnew file mode 100644index 000000000000..a77d2d2a4be7--- /dev/null+++ b/frontend/src/scenes/integrations/postgresql/postgreSQLSetupModalLogic.ts@@ -0,0 +1,72 @@+import { connect, kea, path, props } from 'kea'+import { forms } from 'kea-forms'++import api from 'lib/api'+import { integrationsLogic } from 'lib/integrations/integrationsLogic'+import { lemonToast } from 'lib/lemon-ui/LemonToast'++import type { IntegrationType } from '~/types'++import type { postgreSQLSetupModalLogicType } from './postgreSQLSetupModalLogicType'++export interface PostgreSQLSetupModalLogicProps {+ isOpen: boolean+ integration?: IntegrationType | null+ onComplete: (integrationId?: number) => void+}++export const postgreSQLSetupModalLogic = kea<postgreSQLSetupModalLogicType>([+ path(['integrations', 'postgreSQL', 'postgreSQLSetupModalLogic']),+ props({} as PostgreSQLSetupModalLogicProps),+ connect(() => ({+ actions: [integrationsLogic, ['loadIntegrations']],+ })),+ forms(({ props, actions, values }) => ({+ postgreSQLIntegration: {+ defaults: {+ host: null as string | null,+ port: 5432,+ user: null as string | null,+ password: null as string | null,+ ssl_mode: 'no',+ use_system_ca: false,+ ssl_root_cert: null as string | null,+ },+ errors: ({ host, port, user, password, ssl_mode, use_system_ca, ssl_root_cert }) => ({+ host: host?.trim() ? undefined : 'Host is required',+ port: port ? undefined : 'Port is required',+ user: user?.trim() ? undefined : 'User is required',+ password: password?.trim() ? undefined : 'Password is required',+ ssl_root_cert:+ ssl_mode === 'no' || use_system_ca || ssl_root_cert?.trim()+ ? undefined+ : 'Upload a root certificate, or use the system certificate authorities',+ }),+ submit: async () => {+ try {+ const { host, port, user, password, ssl_mode, use_system_ca, ssl_root_cert } =+ values.postgreSQLIntegration+ const integration = await api.integrations.create({+ kind: 'postgresql',+ config: {+ host: host,+ port: port,+ user: user,+ password: password,+ ...(ssl_mode !== 'no' && {+ ssl_mode: ssl_mode,+ ssl_root_cert: use_system_ca ? 'system' : ssl_root_cert,+ }),+ },+ })+ actions.loadIntegrations()+ lemonToast.success('PostgreSQL integration created successfully!')+ props.onComplete(integration.id)+ } catch (error: any) {+ lemonToast.error(error.detail || 'Failed to create PostgreSQL integration')+ throw error+ }+ },+ },+ })),+])diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex aa871985a557..157b98ae6d39 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -5290,6 +5290,7 @@ export const INTEGRATION_KINDS = ['customerio-app','customerio-webhook','customerio-track',+ 'postgresql',] as constexport type IntegrationKind = (typeof INTEGRATION_KINDS)[number]@@ -6300,11 +6301,12 @@ export type BatchExportServiceS3Compatible = {export type BatchExportServicePostgres = {type: 'Postgres'+ integration?: numberconfig: {- user: string- password: string- host: string- port: number+ user?: string+ password?: string+ host?: string+ port?: numberdatabase: stringschema: stringtable_name: stringdiff --git a/posthog/api/integration.py b/posthog/api/integration.pyindex 101f8ad4bbc6..689404b10abf 100644--- a/posthog/api/integration.py+++ b/posthog/api/integration.py@@ -59,6 +59,7 @@ from posthog.models.integration import (LinearIntegration,LinkedInAdsIntegration,OauthIntegration,+ PostgreSQLIntegration,SlackIntegration,StripeIntegration,TwilioIntegration,@@ -512,6 +513,57 @@ class IntegrationSerializer(serializers.ModelSerializer, UserAccessControlSerialraise ValidationError(str(e))return instance+ elif validated_data["kind"] == "postgresql":+ config = validated_data.get("config", {})+ host = config.get("host")+ port = config.get("port", 5432)+ user = config.get("user")+ password = config.get("password")+ ssl_mode = config.get("ssl_mode", "require")+ ssl_root_cert = config.get("ssl_root_cert")++ if not (host and port and user and password):+ raise ValidationError("Host, port, user, and password must be provided")++ if not all(isinstance(value, str) for value in (host, user, password)):+ raise ValidationError("Host, user, and password must be strings")++ from products.batch_exports.backend.api.batch_export import resolve_and_validate_host++ try:+ resolve_and_validate_host(host)+ except ValueError:+ raise ValidationError(f"Invalid host: '{host}'")++ try:+ port = int(port)+ except (TypeError, ValueError):+ raise ValidationError("Port must be an integer")++ if port < 0 or port > 65535:+ raise ValidationError("Port must be between 0 and 65535")++ if ssl_mode not in ("require", "verify-ca", "verify-full"):+ raise ValidationError("SSL mode must be one of: require, verify-ca, verify-full")++ if ssl_mode in ("verify-ca", "verify-full"):+ if not ssl_root_cert:+ raise ValidationError("Root certificate must be provided when verifying server certificates")+ if not isinstance(ssl_root_cert, str):+ raise ValidationError("Root certificate must be a string")++ instance = PostgreSQLIntegration.integration_from_config(+ team_id=team_id,+ host=host,+ port=port,+ user=user,+ password=password,+ ssl_mode=ssl_mode,+ ssl_root_cert=ssl_root_cert,+ created_by=request.user,+ )+ return instance+elif validated_data["kind"] in OauthIntegration.supported_kinds:# Stripe marketplace installs redirect to /integrations/stripe/callback without# a PostHog-minted CSRF state token — Stripe drives the OAuth flow itself.diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex b53d64807d00..451f88f7e166 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -2169,6 +2169,7 @@ class IntegrationKind(StrEnum):CUSTOMERIO_APP = "customerio-app"CUSTOMERIO_WEBHOOK = "customerio-webhook"CUSTOMERIO_TRACK = "customerio-track"+ POSTGRESQL = "postgresql"class IntervalType(StrEnum):diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.pyindex 91f58495c8fc..cec15c660449 100644--- a/products/batch_exports/backend/api/batch_export.py+++ b/products/batch_exports/backend/api/batch_export.py@@ -286,6 +286,32 @@ class BigQueryDestinationConfigSerializer(serializers.Serializer):)+class PostgresDestinationConfigSerializer(serializers.Serializer):+ """Typed configuration for a PostgreSQL batch-export destination.++ Connection credentials may live in a linked Integration (when one is provided) or+ inline in this config (legacy). Mirrors the non-credential fields of+ `PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.+ """++ database = serializers.CharField(help_text="PostgreSQL database name to connect to.")+ schema = serializers.CharField(+ required=False,+ default="public",+ help_text="PostgreSQL schema name containing the destination table.",+ )+ table_name = serializers.CharField(+ required=False,+ default="events",+ help_text="PostgreSQL table name to write exported rows into.",+ )+ has_self_signed_cert = serializers.BooleanField(+ required=False,+ default=False,+ help_text="Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.",+ )++class AzureBlobDestinationConfigSerializer(serializers.Serializer):"""Typed configuration for an Azure Blob Storage batch-export destination.@@ -328,6 +354,7 @@ class AzureBlobDestinationConfigSerializer(serializers.Serializer):"Databricks": DatabricksDestinationConfigSerializer,"AzureBlob": AzureBlobDestinationConfigSerializer,"BigQuery": BigQueryDestinationConfigSerializer,+ "Postgres": PostgresDestinationConfigSerializer,},resource_type_field_name="type",)@@ -380,12 +407,26 @@ class BigQueryDestinationRequestSerializer(serializers.Serializer):config = BigQueryDestinationConfigSerializer()+class PostgresDestinationRequestSerializer(serializers.Serializer):+ """Request shape for creating or updating a PostgreSQL batch-export destination."""++ type = serializers.ChoiceField(choices=["Postgres"])+ integration_id = serializers.IntegerField(+ help_text=(+ "ID of a postgresql-kind Integration providing connection credentials. Required when creating "+ "a batch export. Use the integrations-list MCP tool to find one."+ ),+ )+ config = PostgresDestinationConfigSerializer()++BatchExportDestinationRequest = PolymorphicProxySerializer(component_name="BatchExportDestinationRequest",serializers={"Databricks": DatabricksDestinationRequestSerializer,"AzureBlob": AzureBlobDestinationRequestSerializer,"BigQuery": BigQueryDestinationRequestSerializer,+ "Postgres": PostgresDestinationRequestSerializer,},resource_type_field_name="type",)@@ -395,10 +436,10 @@ BatchExportDestinationRequest = PolymorphicProxySerializer(class BatchExportDestinationRequestField(serializers.JSONField):"""JSONField annotated with a polymorphic OpenAPI request schema.- Only integration-backed destinations (Databricks, AzureBlob, BigQuery) are exposed in- the schema — their integration_id is required so clients and MCP tools know up front- that these destinations need a linked Integration. Runtime validation remains- `BatchExportDestinationSerializer.validate_destination`.+ Only integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are+ exposed in the schema. integration_id is required when creating any of these. Existing+ Postgres exports created before integrations keep their inline credentials. Runtime+ validation remains `BatchExportDestinationSerializer.validate_destination`."""pass@@ -456,7 +497,7 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):"""Serializer for an BatchExportDestination model.The `config` field is polymorphic and typed only for destinations that keep- credentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).+ credentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).Other destination types accept the same JSON shape but without a typedOpenAPI schema. Secret fields are stripped from `config` on read."""@@ -464,7 +505,7 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):config = TypedBatchExportDestinationConfigField(help_text=("Destination-specific configuration. Fields depend on `type`. Credentials for "- "integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — "+ "integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — ""they live in the linked Integration. Secret fields are stripped from responses."),)@@ -481,8 +522,8 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):required=False,allow_null=True,help_text=(- "ID of a team-scoped Integration providing credentials. Required for Databricks, "- "AzureBlob, and BigQuery destinations; unused for other types."+ "ID of a team-scoped Integration providing credentials. Required when creating Databricks, "+ "AzureBlob, BigQuery, and Postgres destinations; unused for other types."),)@@ -1026,6 +1067,11 @@ class BatchExportSerializer(serializers.ModelSerializer):if destination_type == BatchExportDestination.Destination.POSTGRES:team_id = self.context["team_id"]integration = destination_attrs.get("integration")+ # New Postgres exports must use an Integration for credentials. Exports created before+ # integrations existed keep their inline credentials, so only require it on create+ # (`instance is None`); existing inline-credential exports stay valid when edited.+ if integration is None and instance is None:+ raise serializers.ValidationError("Integration is required for Postgres batch exports")if integration is not None:if integration.team_id != team_id:raise serializers.ValidationError("Integration does not belong to this team.")@@ -1117,10 +1163,21 @@ class BatchExportSerializer(serializers.ModelSerializer):BatchExportDestination.Destination.POSTGRES,BatchExportDestination.Destination.REDSHIFT,):- try:- resolve_and_validate_host(merged_config["host"])- except ValueError:- raise serializers.ValidationError(f"Invalid host: '{merged_config['host']}'")+ # Integration-backed Postgres exports keep the host in the linked Integration+ # rather than in `config`; inline configs (Redshift, legacy Postgres) keep it in+ # `config`. Prefer the Integration's host when one is provided so we don't skip+ # SSRF validation (and don't `KeyError` on a `config` that has no `host`).+ integration = destination_attrs.get("integration")+ if integration is not None:+ host = integration.config.get("host")+ else:+ host = merged_config.get("host")++ if host is not None:+ try:+ resolve_and_validate_host(host)+ except ValueError:+ raise serializers.ValidationError(f"Invalid host: '{host}'")return destination_attrs@@ -1308,7 +1365,8 @@ def recursive_dict_merge(@extend_schema(tags=["batch_exports"])@extend_schema_view(# Request bodies use a polymorphic destination schema so that integration-backed types- # (Databricks, AzureBlob, BigQuery) advertise integration_id as required up front.+ # (Databricks, AzureBlob, BigQuery, Postgres) advertise integration_id up front — required+ # for all of them except Postgres, where it is optional.# Responses continue to use BatchExportSerializer.create=extend_schema(request=BatchExportRequestSerializer),update=extend_schema(request=BatchExportRequestSerializer),diff --git a/products/batch_exports/backend/tests/api/test_create.py b/products/batch_exports/backend/tests/api/test_create.pyindex f398fc89a963..22f916842910 100644--- a/products/batch_exports/backend/tests/api/test_create.py+++ b/products/batch_exports/backend/tests/api/test_create.py@@ -708,38 +708,41 @@ def test_creating_batch_export_with_filters("localhost",],)-def test_create_redshift_or_postgres_batch_export_fails_with_invalid_host(+def test_create_redshift_batch_export_fails_with_invalid_host(client: HttpClient, temporal, organization, team, user, host):- """Test creating a BatchExport with Redshift destination validates inputs for 'COPY'."""+ """Test creating a BatchExport with Redshift destination validates inputs for 'COPY'.- for type in ("Redshift", "Postgres"):- destination_data = {- "type": type,- "config": {- "user": "user",- "password": "my-password",- "database": "my-db",- "host": host,- "schema": "public",- "table_name": "my_events",- },- }+ Postgres host validation is covered separately in test_create_postgres.py, where the host+ comes from the linked Integration rather than from inline config.+ """- batch_export_data = {- "name": "my-production-destination",- "destination": destination_data,- "interval": "hour",- }+ destination_data = {+ "type": "Redshift",+ "config": {+ "user": "user",+ "password": "my-password",+ "database": "my-db",+ "host": host,+ "schema": "public",+ "table_name": "my_events",+ },+ }++ batch_export_data = {+ "name": "my-production-destination",+ "destination": destination_data,+ "interval": "hour",+ }- client.force_login(user)+ client.force_login(user)- with override_settings(TEST=0, DEBUG=0):- response = create_batch_export(- client,- team.pk,- batch_export_data,- )+ with override_settings(TEST=0, DEBUG=0):+ response = create_batch_export(+ client,+ team.pk,+ batch_export_data,+ )- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert f"Invalid host: '{host}'" in response.json()["detail"]+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert f"Invalid host: '{host}'" in response.json()["detail"]diff --git a/products/batch_exports/backend/tests/api/test_create_postgres.py b/products/batch_exports/backend/tests/api/test_create_postgres.pynew file mode 100644index 000000000000..dd59042463f7--- /dev/null+++ b/products/batch_exports/backend/tests/api/test_create_postgres.py@@ -0,0 +1,147 @@+import pytest++from django.test import override_settings+from django.test.client import Client as HttpClient++from rest_framework import status++from posthog.models.integration import Integration++from products.batch_exports.backend.tests.api.operations import create_batch_export++pytestmark = [+ pytest.mark.django_db,+ pytest.mark.usefixtures("temporal_worker", "cleanup"),+]+++def create_postgresql_integration(team, user, host: str) -> Integration:+ """Create a PostgreSQL integration storing connection details, including the host.++ For integration-backed Postgres batch exports the connection credentials (including+ the host) live in the Integration rather than in the destination's `config`.+ """+ return Integration.objects.create(+ team=team,+ kind=Integration.IntegrationKind.POSTGRESQL,+ integration_id=f"{team.pk}-{host}-5432-user",+ config={+ "host": host,+ "port": 5432,+ "user": "user",+ "ssl_mode": "require",+ "ssl_root_cert": None,+ },+ sensitive_config={"password": "my-password"},+ created_by=user,+ )+++def test_creating_postgres_batch_export_using_integration(client: HttpClient, temporal, organization, team, user):+ """Test that we can create a Postgres batch export backed by an integration.++ The host lives in the linked Integration rather than in `config`, so the destination+ config only carries non-credential fields. This path used to raise a `KeyError` (HTTP+ 500) while SSRF-validating `config["host"]`, which does not exist for integration-backed+ exports.+ """+ integration = create_postgresql_integration(team, user, host="8.8.8.8")++ destination_data = {+ "type": "Postgres",+ "config": {+ "database": "my-db",+ "schema": "public",+ "table_name": "my_events",+ },+ "integration": integration.id,+ }++ batch_export_data = {+ "name": "my-postgres-destination",+ "destination": destination_data,+ "interval": "hour",+ }++ client.force_login(user)+ response = create_batch_export(client, team.pk, batch_export_data)++ assert response.status_code == status.HTTP_201_CREATED, response.json()+ assert response.json()["destination"]["integration"] == integration.id+++ "host",+ [+ "169.254.169.254",+ "127.0.0.1",+ "10.0.0.1",+ "192.168.1.1",+ ],+)+def test_creating_postgres_batch_export_validates_integration_host(+ client: HttpClient, temporal, organization, team, user, host+):+ """Test that the integration's host is SSRF-validated when creating a Postgres batch export.++ The host comes from the linked Integration, not from `config`, so this path must still+ reject internal/private hosts rather than skipping host validation altogether.+ """+ integration = create_postgresql_integration(team, user, host=host)++ destination_data = {+ "type": "Postgres",+ "config": {+ "database": "my-db",+ "schema": "public",+ "table_name": "my_events",+ },+ "integration": integration.id,+ }++ batch_export_data = {+ "name": "my-postgres-destination",+ "destination": destination_data,+ "interval": "hour",+ }++ client.force_login(user)+ with override_settings(TEST=0, DEBUG=0):+ response = create_batch_export(client, team.pk, batch_export_data)++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert f"Invalid host: '{host}'" in response.json()["detail"]+++def test_creating_postgres_batch_export_without_integration_is_rejected(+ client: HttpClient, temporal, organization, team, user+):+ """Test that creating a new Postgres batch export without an integration is rejected.++ New Postgres exports must store credentials in a linked Integration; inline credentials (the+ legacy path) are no longer accepted on create.+ """+ destination_data = {+ "type": "Postgres",+ "config": {+ "user": "user",+ "password": "my-password",+ "host": "8.8.8.8",+ "port": 5432,+ "database": "my-db",+ "schema": "public",+ "table_name": "my_events",+ },+ }++ batch_export_data = {+ "name": "my-postgres-destination",+ "destination": destination_data,+ "interval": "hour",+ }++ client.force_login(user)+ response = create_batch_export(client, team.pk, batch_export_data)++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert "Integration is required for Postgres batch exports" in response.json()["detail"]diff --git a/products/batch_exports/backend/tests/api/test_get.py b/products/batch_exports/backend/tests/api/test_get.pyindex 149c156dfb2d..f9becfbc46c2 100644--- a/products/batch_exports/backend/tests/api/test_get.py+++ b/products/batch_exports/backend/tests/api/test_get.py@@ -7,6 +7,7 @@ from rest_framework import statusfrom posthog.api.test.test_team import create_teamfrom posthog.api.test.test_user import create_user+from products.batch_exports.backend.models.batch_export import BatchExport, BatchExportDestinationfrom products.batch_exports.backend.tests.api.fixtures import create_organizationfrom products.batch_exports.backend.tests.api.operations import create_batch_export_ok, get_batch_export@@ -183,22 +184,16 @@ def test_serialization_of_destination_config(client: HttpClient, temporal, organ},}- batch_export_data = {- "name": "my-export",- "destination": destination_data,- "interval": "day",- "timezone": "UTC",- }-- client.force_login(user)-- response = create_batch_export_ok(- client,- team.pk,- batch_export_data,+ # Created via the ORM to exercise an inline-credential (legacy) Postgres export, which can no+ # longer be created through the API now that new Postgres exports require an integration.+ destination = BatchExportDestination.objects.create(+ type=BatchExportDestination.Destination.POSTGRES,+ config=destination_data["config"],)+ batch_export = BatchExport.objects.create(name="my-export", team=team, destination=destination, interval="day")- response = get_batch_export(client, team.pk, response["id"])+ client.force_login(user)+ response = get_batch_export(client, team.pk, batch_export.id)assert response.status_code == status.HTTP_200_OK, response.json()batch_export = response.json()diff --git a/products/batch_exports/backend/tests/api/test_update.py b/products/batch_exports/backend/tests/api/test_update.pyindex 3061d497bc3f..956423aab531 100644--- a/products/batch_exports/backend/tests/api/test_update.py+++ b/products/batch_exports/backend/tests/api/test_update.py@@ -918,3 +918,42 @@ def test_can_update_batch_export_with_integration_to_none(response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)assert response.status_code == status.HTTP_400_BAD_REQUESTassert "Integration is required for Databricks batch exports" in response.json()["detail"]+++def test_updating_legacy_postgres_batch_export_keeps_inline_credentials(+ client: HttpClient, temporal, organization, team, user+):+ """Test that existing inline-credential Postgres exports are grandfathered when edited.++ Exports created before integrations existed have no linked integration. Editing them must+ not force migrating to an integration, so the integration requirement applies on create only.+ """+ destination = BatchExportDestination.objects.create(+ type=BatchExportDestination.Destination.POSTGRES,+ config={+ "user": "user",+ "password": "my-password",+ "host": "8.8.8.8",+ "port": 5432,+ "database": "my-db",+ "schema": "public",+ "table_name": "my_events",+ },+ )+ batch_export = BatchExport.objects.create(+ name="legacy-postgres-export", team=team, destination=destination, interval="hour"+ )+ sync_batch_export(batch_export, created=True)++ client.force_login(user)+ new_batch_export_data = {+ "destination": {+ "type": "Postgres",+ "config": {"table_name": "my_new_events"},+ },+ }+ response = patch_batch_export(client, team.pk, batch_export.id, new_batch_export_data)++ assert response.status_code == status.HTTP_200_OK, response.json()+ updated = get_batch_export_ok(client, team.pk, batch_export.id)+ assert updated["destination"]["config"]["table_name"] == "my_new_events"diff --git a/products/batch_exports/frontend/generated/api.schemas.ts b/products/batch_exports/frontend/generated/api.schemas.tsindex e6e600488083..14228a0f1385 100644--- a/products/batch_exports/frontend/generated/api.schemas.ts+++ b/products/batch_exports/frontend/generated/api.schemas.ts@@ -180,16 +180,43 @@ export interface BigQueryDestinationConfigApi {type: BigQueryDestinationConfigApiType}+export type PostgresDestinationConfigApiType =+ (typeof PostgresDestinationConfigApiType)[keyof typeof PostgresDestinationConfigApiType]++export const PostgresDestinationConfigApiType = {+ Postgres: 'Postgres',+} as const++/**+ * Typed configuration for a PostgreSQL batch-export destination.+ *+ * Connection credentials may live in a linked Integration (when one is provided) or+ * inline in this config (legacy). Mirrors the non-credential fields of+ * `PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.+ */+export interface PostgresDestinationConfigApi {+ /** PostgreSQL database name to connect to. */+ database: string+ /** PostgreSQL schema name containing the destination table. */+ schema?: string+ /** PostgreSQL table name to write exported rows into. */+ table_name?: string+ /** Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration. */+ has_self_signed_cert?: boolean+ type: PostgresDestinationConfigApiType+}+export type BatchExportDestinationConfigApi =| DatabricksDestinationConfigApi| AzureBlobDestinationConfigApi| BigQueryDestinationConfigApi+ | PostgresDestinationConfigApi/*** Serializer for an BatchExportDestination model.** The `config` field is polymorphic and typed only for destinations that keep- * credentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).+ * credentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).* Other destination types accept the same JSON shape but without a typed* OpenAPI schema. Secret fields are stripped from `config` on read.*/@@ -210,7 +237,7 @@ export interface BatchExportDestinationApi {* * `NoOp` - Noop* * `FileDownload` - File Download */type: BatchExportDestinationTypeEnumApi- /** Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses. */+ /** Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses. */config: BatchExportDestinationConfigApi/*** The integration for this destination.@@ -218,7 +245,7 @@ export interface BatchExportDestinationApi {*/integration?: number | null/**- * ID of a team-scoped Integration providing credentials. Required for Databricks, AzureBlob, and BigQuery destinations; unused for other types.+ * ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, and Postgres destinations; unused for other types.* @nullable*/integration_id?: number | null@@ -1085,10 +1112,28 @@ export interface BigQueryDestinationRequestApi {config: BigQueryDestinationConfigApi}+export type PostgresDestinationRequestApiType =+ (typeof PostgresDestinationRequestApiType)[keyof typeof PostgresDestinationRequestApiType]++export const PostgresDestinationRequestApiType = {+ Postgres: 'Postgres',+} as const++/**+ * Request shape for creating or updating a PostgreSQL batch-export destination.+ */+export interface PostgresDestinationRequestApi {+ type: PostgresDestinationRequestApiType+ /** ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one. */+ integration_id: number+ config: PostgresDestinationConfigApi+}+export type BatchExportDestinationRequestApi =| DatabricksDestinationRequestApi| AzureBlobDestinationRequestApi| BigQueryDestinationRequestApi+ | PostgresDestinationRequestApi/*** Request body for create/partial_update on BatchExportViewSet.@@ -1604,6 +1649,16 @@ export const BigQueryDestinationRequestTypeEnumApi = {BigQuery: 'BigQuery',} as const+/**+ * * `Postgres` - Postgres+ */+export type PostgresDestinationRequestTypeEnumApi =+ (typeof PostgresDestinationRequestTypeEnumApi)[keyof typeof PostgresDestinationRequestTypeEnumApi]++export const PostgresDestinationRequestTypeEnumApi = {+ Postgres: 'Postgres',+} as const+export type BatchExportsListParams = {/*** Number of results to return per page.diff --git a/products/batch_exports/frontend/generated/api.zod.ts b/products/batch_exports/frontend/generated/api.zod.tsindex a7dc7d09f407..4e050da89ac2 100644--- a/products/batch_exports/frontend/generated/api.zod.ts+++ b/products/batch_exports/frontend/generated/api.zod.ts@@ -15,6 +15,9 @@ export const batchExportsCreateBodyDestinationOneTwoConfigPrefixDefault = ``export const batchExportsCreateBodyDestinationOneTwoConfigFileFormatDefault = `JSONLines`export const batchExportsCreateBodyDestinationOneThreeConfigTableIdDefault = `events`export const batchExportsCreateBodyDestinationOneThreeConfigUseJsonTypeDefault = false+export const batchExportsCreateBodyDestinationOneFourConfigSchemaDefault = `public`+export const batchExportsCreateBodyDestinationOneFourConfigTableNameDefault = `events`+export const batchExportsCreateBodyDestinationOneFourConfigHasSelfSignedCertDefault = falseexport const batchExportsCreateBodyOffsetDayMin = 0export const batchExportsCreateBodyOffsetDayMax = 6@@ -142,6 +145,38 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zod),}).describe('Request shape for creating or updating a BigQuery batch-export destination.'),+ zod+ .object({+ type: zod.enum(['Postgres']),+ integration_id: zod+ .number()+ .describe(+ 'ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ ),+ config: zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsCreateBodyDestinationOneFourConfigSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsCreateBodyDestinationOneFourConfigTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(batchExportsCreateBodyDestinationOneFourConfigHasSelfSignedCertDefault)+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),+ })+ .describe('Request shape for creating or updating a PostgreSQL batch-export destination.'),]).describe('Destination configuration. Required integration_id is enforced per destination type.'),interval: zod@@ -434,6 +469,9 @@ export const batchExportsUpdateBodyDestinationOneTwoConfigPrefixDefault = ``export const batchExportsUpdateBodyDestinationOneTwoConfigFileFormatDefault = `JSONLines`export const batchExportsUpdateBodyDestinationOneThreeConfigTableIdDefault = `events`export const batchExportsUpdateBodyDestinationOneThreeConfigUseJsonTypeDefault = false+export const batchExportsUpdateBodyDestinationOneFourConfigSchemaDefault = `public`+export const batchExportsUpdateBodyDestinationOneFourConfigTableNameDefault = `events`+export const batchExportsUpdateBodyDestinationOneFourConfigHasSelfSignedCertDefault = falseexport const batchExportsUpdateBodyOffsetDayMin = 0export const batchExportsUpdateBodyOffsetDayMax = 6@@ -561,6 +599,38 @@ export const BatchExportsUpdateBody = /* @__PURE__ */ zod),}).describe('Request shape for creating or updating a BigQuery batch-export destination.'),+ zod+ .object({+ type: zod.enum(['Postgres']),+ integration_id: zod+ .number()+ .describe(+ 'ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ ),+ config: zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsUpdateBodyDestinationOneFourConfigSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsUpdateBodyDestinationOneFourConfigTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(batchExportsUpdateBodyDestinationOneFourConfigHasSelfSignedCertDefault)+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),+ })+ .describe('Request shape for creating or updating a PostgreSQL batch-export destination.'),]).describe('Destination configuration. Required integration_id is enforced per destination type.'),interval: zod@@ -606,6 +676,9 @@ export const batchExportsPartialUpdateBodyDestinationOneTwoConfigPrefixDefault =export const batchExportsPartialUpdateBodyDestinationOneTwoConfigFileFormatDefault = `JSONLines`export const batchExportsPartialUpdateBodyDestinationOneThreeConfigTableIdDefault = `events`export const batchExportsPartialUpdateBodyDestinationOneThreeConfigUseJsonTypeDefault = false+export const batchExportsPartialUpdateBodyDestinationOneFourConfigSchemaDefault = `public`+export const batchExportsPartialUpdateBodyDestinationOneFourConfigTableNameDefault = `events`+export const batchExportsPartialUpdateBodyDestinationOneFourConfigHasSelfSignedCertDefault = falseexport const batchExportsPartialUpdateBodyOffsetDayMin = 0export const batchExportsPartialUpdateBodyOffsetDayMax = 6@@ -733,6 +806,40 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zod),}).describe('Request shape for creating or updating a BigQuery batch-export destination.'),+ zod+ .object({+ type: zod.enum(['Postgres']),+ integration_id: zod+ .number()+ .describe(+ 'ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ ),+ config: zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsPartialUpdateBodyDestinationOneFourConfigSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsPartialUpdateBodyDestinationOneFourConfigTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(+ batchExportsPartialUpdateBodyDestinationOneFourConfigHasSelfSignedCertDefault+ )+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),+ })+ .describe('Request shape for creating or updating a PostgreSQL batch-export destination.'),]).optional().describe('Destination configuration. Required integration_id is enforced per destination type.'),@@ -783,6 +890,9 @@ export const batchExportsPauseCreateBodyDestinationOneConfigOneTwoPrefixDefaultexport const batchExportsPauseCreateBodyDestinationOneConfigOneTwoFileFormatDefault = `JSONLines`export const batchExportsPauseCreateBodyDestinationOneConfigOneThreeTableIdDefault = `events`export const batchExportsPauseCreateBodyDestinationOneConfigOneThreeUseJsonTypeDefault = false+export const batchExportsPauseCreateBodyDestinationOneConfigOneFourSchemaDefault = `public`+export const batchExportsPauseCreateBodyDestinationOneConfigOneFourTableNameDefault = `events`+export const batchExportsPauseCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault = falseexport const batchExportsPauseCreateBodyOffsetDayMin = 0export const batchExportsPauseCreateBodyOffsetDayMax = 6@@ -909,20 +1019,44 @@ export const BatchExportsPauseCreateBody = /* @__PURE__ */ zod.describe('Typed configuration for a BigQuery batch-export destination.\n\nCredentials live in the linked Integration, not in this config. Mirrors the\nnon-credential fields of `BigQueryBatchExportInputs` in\n`products\/batch_exports\/backend\/service.py`.'),+ zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsPauseCreateBodyDestinationOneConfigOneFourSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsPauseCreateBodyDestinationOneConfigOneFourTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(+ batchExportsPauseCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault+ )+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),]).describe(- 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'+ 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'),integration: zod.number().nullish().describe('The integration for this destination.'),integration_id: zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required for Databricks, AzureBlob, and BigQuery destinations; unused for other types.'+ 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, and Postgres destinations; unused for other types.'),}).describe(- 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.'+ 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.').describe('Destination configuration (type, config, and optional integration).'),interval: zod@@ -982,6 +1116,9 @@ export const batchExportsRunTestStepCreateBodyDestinationOneConfigOneTwoPrefixDeexport const batchExportsRunTestStepCreateBodyDestinationOneConfigOneTwoFileFormatDefault = `JSONLines`export const batchExportsRunTestStepCreateBodyDestinationOneConfigOneThreeTableIdDefault = `events`export const batchExportsRunTestStepCreateBodyDestinationOneConfigOneThreeUseJsonTypeDefault = false+export const batchExportsRunTestStepCreateBodyDestinationOneConfigOneFourSchemaDefault = `public`+export const batchExportsRunTestStepCreateBodyDestinationOneConfigOneFourTableNameDefault = `events`+export const batchExportsRunTestStepCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault = falseexport const batchExportsRunTestStepCreateBodyOffsetDayMin = 0export const batchExportsRunTestStepCreateBodyOffsetDayMax = 6@@ -1116,20 +1253,46 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod.describe('Typed configuration for a BigQuery batch-export destination.\n\nCredentials live in the linked Integration, not in this config. Mirrors the\nnon-credential fields of `BigQueryBatchExportInputs` in\n`products\/batch_exports\/backend\/service.py`.'),+ zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsRunTestStepCreateBodyDestinationOneConfigOneFourSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(+ batchExportsRunTestStepCreateBodyDestinationOneConfigOneFourTableNameDefault+ )+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(+ batchExportsRunTestStepCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault+ )+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),]).describe(- 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'+ 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'),integration: zod.number().nullish().describe('The integration for this destination.'),integration_id: zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required for Databricks, AzureBlob, and BigQuery destinations; unused for other types.'+ 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, and Postgres destinations; unused for other types.'),}).describe(- 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.'+ 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.').describe('Destination configuration (type, config, and optional integration).'),interval: zod@@ -1192,6 +1355,9 @@ export const batchExportsUnpauseCreateBodyDestinationOneConfigOneTwoPrefixDefaulexport const batchExportsUnpauseCreateBodyDestinationOneConfigOneTwoFileFormatDefault = `JSONLines`export const batchExportsUnpauseCreateBodyDestinationOneConfigOneThreeTableIdDefault = `events`export const batchExportsUnpauseCreateBodyDestinationOneConfigOneThreeUseJsonTypeDefault = false+export const batchExportsUnpauseCreateBodyDestinationOneConfigOneFourSchemaDefault = `public`+export const batchExportsUnpauseCreateBodyDestinationOneConfigOneFourTableNameDefault = `events`+export const batchExportsUnpauseCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault = falseexport const batchExportsUnpauseCreateBodyOffsetDayMin = 0export const batchExportsUnpauseCreateBodyOffsetDayMax = 6@@ -1322,20 +1488,44 @@ export const BatchExportsUnpauseCreateBody = /* @__PURE__ */ zod.describe('Typed configuration for a BigQuery batch-export destination.\n\nCredentials live in the linked Integration, not in this config. Mirrors the\nnon-credential fields of `BigQueryBatchExportInputs` in\n`products\/batch_exports\/backend\/service.py`.'),+ zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsUnpauseCreateBodyDestinationOneConfigOneFourSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsUnpauseCreateBodyDestinationOneConfigOneFourTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(+ batchExportsUnpauseCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault+ )+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),]).describe(- 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'+ 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'),integration: zod.number().nullish().describe('The integration for this destination.'),integration_id: zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required for Databricks, AzureBlob, and BigQuery destinations; unused for other types.'+ 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, and Postgres destinations; unused for other types.'),}).describe(- 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.'+ 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.').describe('Destination configuration (type, config, and optional integration).'),interval: zod@@ -1395,6 +1585,9 @@ export const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneTwoPrefiexport const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneTwoFileFormatDefault = `JSONLines`export const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneThreeTableIdDefault = `events`export const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneThreeUseJsonTypeDefault = false+export const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneFourSchemaDefault = `public`+export const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneFourTableNameDefault = `events`+export const batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault = falseexport const batchExportsRunTestStepNewCreateBodyOffsetDayMin = 0export const batchExportsRunTestStepNewCreateBodyOffsetDayMax = 6@@ -1531,20 +1724,48 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod.describe('Typed configuration for a BigQuery batch-export destination.\n\nCredentials live in the linked Integration, not in this config. Mirrors the\nnon-credential fields of `BigQueryBatchExportInputs` in\n`products\/batch_exports\/backend\/service.py`.'),+ zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(+ batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneFourSchemaDefault+ )+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(+ batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneFourTableNameDefault+ )+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(+ batchExportsRunTestStepNewCreateBodyDestinationOneConfigOneFourHasSelfSignedCertDefault+ )+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ type: zod.enum(['Postgres']),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products\/batch_exports\/backend\/service.py`.'+ ),]).describe(- 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'+ 'Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses.'),integration: zod.number().nullish().describe('The integration for this destination.'),integration_id: zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required for Databricks, AzureBlob, and BigQuery destinations; unused for other types.'+ 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, and Postgres destinations; unused for other types.'),}).describe(- 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.'+ 'Serializer for an BatchExportDestination model.\n\nThe `config` field is polymorphic and typed only for destinations that keep\ncredentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).\nOther destination types accept the same JSON shape but without a typed\nOpenAPI schema. Secret fields are stripped from `config` on read.').describe('Destination configuration (type, config, and optional integration).'),interval: zoddiff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 149d9a3652b1..661a6e34ff3a 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -4236,6 +4236,7 @@ export const IntegrationKindApi = {CustomerioApp: 'customerio-app',CustomerioWebhook: 'customerio-webhook',CustomerioTrack: 'customerio-track',+ Postgresql: 'postgresql',} as constexport interface ErrorTrackingExternalReferenceIntegrationApi {diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex a4e17fc92af0..e7096b3d2650 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -3676,6 +3676,7 @@ export const IntegrationKindApi = {CustomerioApp: 'customerio-app',CustomerioWebhook: 'customerio-webhook',CustomerioTrack: 'customerio-track',+ Postgresql: 'postgresql',} as constexport interface ErrorTrackingExternalReferenceIntegrationApi {diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 52fe5b0e882e..4f91c00cc743 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -4996,6 +4996,7 @@ export namespace Schemas {CustomerioApp: 'customerio-app',CustomerioWebhook: 'customerio-webhook',CustomerioTrack: 'customerio-track',+ Postgresql: 'postgresql',} as const;export interface ErrorTrackingExternalReferenceIntegration {@@ -10155,13 +10156,39 @@ export namespace Schemas {type: BigQueryDestinationConfigType;}- export type BatchExportDestinationConfig = DatabricksDestinationConfig | AzureBlobDestinationConfig | BigQueryDestinationConfig;+ export type PostgresDestinationConfigType = typeof PostgresDestinationConfigType[keyof typeof PostgresDestinationConfigType];+++ export const PostgresDestinationConfigType = {+ Postgres: 'Postgres',+ } as const;++ /**+ * Typed configuration for a PostgreSQL batch-export destination.+ *+ * Connection credentials may live in a linked Integration (when one is provided) or+ * inline in this config (legacy). Mirrors the non-credential fields of+ * `PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.+ */+ export interface PostgresDestinationConfig {+ /** PostgreSQL database name to connect to. */+ database: string;+ /** PostgreSQL schema name containing the destination table. */+ schema?: string;+ /** PostgreSQL table name to write exported rows into. */+ table_name?: string;+ /** Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration. */+ has_self_signed_cert?: boolean;+ type: PostgresDestinationConfigType;+ }++ export type BatchExportDestinationConfig = DatabricksDestinationConfig | AzureBlobDestinationConfig | BigQueryDestinationConfig | PostgresDestinationConfig;/*** Serializer for an BatchExportDestination model.** The `config` field is polymorphic and typed only for destinations that keep- * credentials in the linked Integration (currently Databricks, AzureBlob, BigQuery).+ * credentials in the linked Integration (currently Databricks, AzureBlob, BigQuery, Postgres).* Other destination types accept the same JSON shape but without a typed* OpenAPI schema. Secret fields are stripped from `config` on read.*/@@ -10182,7 +10209,7 @@ export namespace Schemas {* * `NoOp` - Noop* * `FileDownload` - File Download */type: BatchExportDestinationTypeEnum;- /** Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses. */+ /** Destination-specific configuration. Fields depend on `type`. Credentials for integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres) are NOT stored here — they live in the linked Integration. Secret fields are stripped from responses. */config: BatchExportDestinationConfig;/*** The integration for this destination.@@ -10190,7 +10217,7 @@ export namespace Schemas {*/integration?: number | null;/**- * ID of a team-scoped Integration providing credentials. Required for Databricks, AzureBlob, and BigQuery destinations; unused for other types.+ * ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, and Postgres destinations; unused for other types.* @nullable*/integration_id?: number | null;@@ -11124,7 +11151,24 @@ export namespace Schemas {config: BigQueryDestinationConfig;}- export type BatchExportDestinationRequest = DatabricksDestinationRequest | AzureBlobDestinationRequest | BigQueryDestinationRequest;+ export type PostgresDestinationRequestType = typeof PostgresDestinationRequestType[keyof typeof PostgresDestinationRequestType];+++ export const PostgresDestinationRequestType = {+ Postgres: 'Postgres',+ } as const;++ /**+ * Request shape for creating or updating a PostgreSQL batch-export destination.+ */+ export interface PostgresDestinationRequest {+ type: PostgresDestinationRequestType;+ /** ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one. */+ integration_id: number;+ config: PostgresDestinationConfig;+ }++ export type BatchExportDestinationRequest = DatabricksDestinationRequest | AzureBlobDestinationRequest | BigQueryDestinationRequest | PostgresDestinationRequest;/*** Request body for create/partial_update on BatchExportViewSet.@@ -40140,6 +40184,16 @@ export namespace Schemas {homepage?: PinnedSceneTab | null;}+ /**+ * * `Postgres` - Postgres+ */+ export type PostgresDestinationRequestTypeEnum = typeof PostgresDestinationRequestTypeEnum[keyof typeof PostgresDestinationRequestTypeEnum];+++ export const PostgresDestinationRequestTypeEnum = {+ Postgres: 'Postgres',+ } as const;+export interface PreviewInviteRequest {/*** Which targeted interviewee to render the preview for (an email or PostHog distinct ID already on the topic). Leave blank to preview for the first targeted interviewee.diff --git a/services/mcp/src/generated/batch_exports/api.ts b/services/mcp/src/generated/batch_exports/api.tsindex f5134a60208a..bb60e715c42c 100644--- a/services/mcp/src/generated/batch_exports/api.ts+++ b/services/mcp/src/generated/batch_exports/api.ts@@ -35,6 +35,9 @@ export const batchExportsCreateBodyDestinationOneTwoConfigPrefixDefault = ``export const batchExportsCreateBodyDestinationOneTwoConfigFileFormatDefault = `JSONLines`export const batchExportsCreateBodyDestinationOneThreeConfigTableIdDefault = `events`export const batchExportsCreateBodyDestinationOneThreeConfigUseJsonTypeDefault = false+export const batchExportsCreateBodyDestinationOneFourConfigSchemaDefault = `public`+export const batchExportsCreateBodyDestinationOneFourConfigTableNameDefault = `events`+export const batchExportsCreateBodyDestinationOneFourConfigHasSelfSignedCertDefault = falseexport const batchExportsCreateBodyOffsetDayMin = 0export const batchExportsCreateBodyOffsetDayMax = 6@@ -159,6 +162,37 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zod),}).describe('Request shape for creating or updating a BigQuery batch-export destination.'),+ zod+ .object({+ type: zod.enum(['Postgres']),+ integration_id: zod+ .number()+ .describe(+ 'ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ ),+ config: zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsCreateBodyDestinationOneFourConfigSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsCreateBodyDestinationOneFourConfigTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(batchExportsCreateBodyDestinationOneFourConfigHasSelfSignedCertDefault)+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.'+ ),+ })+ .describe('Request shape for creating or updating a PostgreSQL batch-export destination.'),]).describe('Destination configuration. Required integration_id is enforced per destination type.'),interval: zod@@ -217,6 +251,9 @@ export const batchExportsPartialUpdateBodyDestinationOneTwoConfigPrefixDefault =export const batchExportsPartialUpdateBodyDestinationOneTwoConfigFileFormatDefault = `JSONLines`export const batchExportsPartialUpdateBodyDestinationOneThreeConfigTableIdDefault = `events`export const batchExportsPartialUpdateBodyDestinationOneThreeConfigUseJsonTypeDefault = false+export const batchExportsPartialUpdateBodyDestinationOneFourConfigSchemaDefault = `public`+export const batchExportsPartialUpdateBodyDestinationOneFourConfigTableNameDefault = `events`+export const batchExportsPartialUpdateBodyDestinationOneFourConfigHasSelfSignedCertDefault = falseexport const batchExportsPartialUpdateBodyOffsetDayMin = 0export const batchExportsPartialUpdateBodyOffsetDayMax = 6@@ -341,6 +378,39 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zod),}).describe('Request shape for creating or updating a BigQuery batch-export destination.'),+ zod+ .object({+ type: zod.enum(['Postgres']),+ integration_id: zod+ .number()+ .describe(+ 'ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ ),+ config: zod+ .object({+ database: zod.string().describe('PostgreSQL database name to connect to.'),+ schema: zod+ .string()+ .default(batchExportsPartialUpdateBodyDestinationOneFourConfigSchemaDefault)+ .describe('PostgreSQL schema name containing the destination table.'),+ table_name: zod+ .string()+ .default(batchExportsPartialUpdateBodyDestinationOneFourConfigTableNameDefault)+ .describe('PostgreSQL table name to write exported rows into.'),+ has_self_signed_cert: zod+ .boolean()+ .default(+ batchExportsPartialUpdateBodyDestinationOneFourConfigHasSelfSignedCertDefault+ )+ .describe(+ 'Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.'+ ),+ })+ .describe(+ 'Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.'+ ),+ })+ .describe('Request shape for creating or updating a PostgreSQL batch-export destination.'),]).optional().describe('Destination configuration. Required integration_id is enforced per destination type.'),diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.jsonindex 84cc52aeda44..030052b82848 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json@@ -148,6 +148,47 @@},"required": ["type", "integration_id", "config"],"type": "object"+ },+ {+ "description": "Request shape for creating or updating a PostgreSQL batch-export destination.",+ "properties": {+ "config": {+ "description": "Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.",+ "properties": {+ "database": {+ "description": "PostgreSQL database name to connect to.",+ "type": "string"+ },+ "has_self_signed_cert": {+ "default": false,+ "description": "Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.",+ "type": "boolean"+ },+ "schema": {+ "default": "public",+ "description": "PostgreSQL schema name containing the destination table.",+ "type": "string"+ },+ "table_name": {+ "default": "events",+ "description": "PostgreSQL table name to write exported rows into.",+ "type": "string"+ }+ },+ "required": ["database"],+ "type": "object"+ },+ "integration_id": {+ "description": "ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.",+ "type": "number"+ },+ "type": {+ "enum": ["Postgres"],+ "type": "string"+ }+ },+ "required": ["type", "integration_id", "config"],+ "type": "object"}],"description": "Destination configuration. Required integration_id is enforced per destination type."diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.jsonindex 9519d602117a..341e393f8718 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json@@ -147,6 +147,47 @@},"required": ["type", "integration_id", "config"],"type": "object"+ },+ {+ "description": "Request shape for creating or updating a PostgreSQL batch-export destination.",+ "properties": {+ "config": {+ "description": "Typed configuration for a PostgreSQL batch-export destination.\n\nConnection credentials may live in a linked Integration (when one is provided) or\ninline in this config (legacy). Mirrors the non-credential fields of\n`PostgresBatchExportInputs` in `products/batch_exports/backend/service.py`.",+ "properties": {+ "database": {+ "description": "PostgreSQL database name to connect to.",+ "type": "string"+ },+ "has_self_signed_cert": {+ "default": false,+ "description": "Legacy SSL option for direct credential configuration. Ignored when using a PostgreSQL integration.",+ "type": "boolean"+ },+ "schema": {+ "default": "public",+ "description": "PostgreSQL schema name containing the destination table.",+ "type": "string"+ },+ "table_name": {+ "default": "events",+ "description": "PostgreSQL table name to write exported rows into.",+ "type": "string"+ }+ },+ "required": ["database"],+ "type": "object"+ },+ "integration_id": {+ "description": "ID of a postgresql-kind Integration providing connection credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.",+ "type": "number"+ },+ "type": {+ "enum": ["Postgres"],+ "type": "string"+ }+ },+ "required": ["type", "integration_id", "config"],+ "type": "object"}],"description": "Destination configuration. Required integration_id is enforced per destination type."