For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inBook a demo
GuidesAPI Reference
GuidesAPI Reference
  • Getting started
    • Introduction
    • IP Whitelisting
    • Obtaining API keys
    • LLMs.txt
    • MCP server
    • Quickstart
    • Native clients
    • Concepts
    • Embedding authentication
    • Versioning
    • Idempotent requests
    • Events
    • Self-hosted option
    • 2025-09-18 Migration Guide
  • Configuring your connections
    • Overview
    • CDC streaming from databases
    • Syncing to custom webhooks
  • Code examples
    • Overview
    • Bulk sync (ELT) from HubSpot to PostgreSQL
    • Bulk sync (ELT) from Salesforce to S3
    • Bulk sync (ELT) from Salesforce to Snowflake
    • Model sync (Reverse ETL) from Snowflake query to Salesforce
    • Model sync (Reverse ETL) from MongoDB to Salesforce
    • Adding users from Snowflake to Salesloft Cadence
    • Adding contacts from Snowflake to Gong Engage
    • Joined model sync from Postgres, Airtable, and Stripe to Hubspot
    • Model sync from MySQL to Snowflake
    • Model sync from Salesforce to Netsuite
    • Querying Salesforce using SOQL
    • Syncing audiences from Snowflake to LinkedIn Ads
    • Syncing contacts from Google Cloud Storage to Salesforce
    • Syncing contacts from Google Cloud Storage to webhooks
  • Terraform examples
    • Overview
    • Model sync (Reverse ETL) from BigQuery to Salesforce
    • Model sync (Reverse ETL) from BigQuery to LinkedIn Ads
Logo
Log inBook a demo
On this page
  • UI demo video
  • Code
  • Step 1: Create Connections
  • Step 2: Create joined models
  • Step 3: Sync the joined data to HubSpot
Code examples

Joined model sync from Postgres, Airtable, and Stripe to Hubspot

Was this page helpful?
Previous

Model sync from MySQL to Snowflake

Next

UI demo video

Watch the same steps in the Polytomic admin console in this demo video.

Code

Set your Polytomic API key as an environment variable:

$export POLYTOMIC_API_KEY=YOUR-API-TOKEN

This example covers three steps:

  1. Create Airtable, Stripe, Postgres, and HubSpot Connections.
  2. Join the Airtable, Stripe, and Postgres data with Polytomic models.
  3. Sync the joined data to HubSpot.

Step 1: Create Connections

The following request creates an Airtable Connection. See the Airtable connection configuration for the required fields.

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/connections \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "Airtable Connection",
> "type": "airtable",
> "configuration": {}
> }'

Airtable Connections authenticate with OAuth. Open the URL returned in the auth_url field of the response to complete the flow.

OAuth redirection

By default, the API expects auth_url to open in a new browser window. Set the optional redirect_url parameter in the request body to change the redirect target.

The following request creates a Postgres Connection. See the Postgres connection configuration for the required fields.

The PostgreSQL server must be reachable from Polytomic over the network.

cURL
Python
Typescript
Go
$ curl --request POST \
> --url https://app.polytomic.com/api/connections \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "Postgres Connection",
> "type": "postgresql",
> "configuration": {
> "hostname": "localhost",
> "port": 5432,
> "database": "postgres",
> "username": "user",
> "password": "secret"
> }
> }'

The following request creates a Stripe Connection. See the Stripe connection configuration for the required fields.

cURL
Python
Typescript
Go
$ curl --request POST \
> --url https://app.polytomic.com/api/connections \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "Stripe Connection",
> "type": "stripe",
> "configuration": {
> "api_key": "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
> }
> }'

The following request creates a HubSpot Connection. See the HubSpot connection configuration for the required fields.

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/connections \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{"name": "HubSpot Connection","type": "hubspot", "configuration": {}}'

HubSpot Connections authenticate with OAuth. Open the URL returned in the auth_url field of the response to complete the flow.

OAuth Redirection

By default, the API expects the auth_url to be open in a new browser window. If you’d like to modify the redirect behavior, there is an optional redirect_url parameter that can be added to the request body.

Step 2: Create joined models

The following request creates a User Details model over the Postgres users table:

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/models \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "User Details",
> "configuration": {
> "table": "users"
> },
> "connection_id": "YOUR-POSTGRES-CONNECTION-ID"
> }'

The following request creates a Customers model from Stripe, joined to User Details on the email field:

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/models \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "Customers",
> "configuration": {
> "stream_id": "customers"
> },
> "fields": ["balance", "description", "livemode"],
> "relations": [
> {
> "from": "email",
> "to": {
> "field": "email",
> "model_id": "YOUR-POSTGRES-MODEL-ID"
> }
> }
> ],
> "connection_id": "YOUR-STRIPE-CONNECTION-ID"
> }'

The following request creates a Stars Data model from Airtable, joined to User Details on the email field:

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/models \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "Customers",
> "configuration": {
> "tableobj": {
> "value": "tblOuVBnPKvXjYhqP",
> "label": "Table 1"
> },
> "viewobj": {},
> "baseobj": {
> "value": "appDVrQJeb9w2F2IL",
> "label": "User sample"
> },
> "fields": ["fldR3dERuDqosnxFY"],
> "relations": [
> {
> "from": "fldR3dERuDqosnxFY",
> "to": {
> "field": "email",
> "model_id": "YOUR-POSTGRES-MODEL-ID"
> }
> }
> ],
> "connection_id": "YOUR-AIRTABLE-CONNECTION-ID"
> }'

Step 3: Sync the joined data to HubSpot

The following request creates a Model Sync that loads the joined data into HubSpot:

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/syncs \
> --header 'X-Polytomic-Version: 2024-02-08' \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> --header 'content-type: application/json' \
> -d '{
> "name": "Customer data to HubSpot Sync",
> "mode": "updateOrCreate",
> "fields": [
> {
> "source": {
> "model_id": "YOUR-POSTGRES-MODEL-ID",
> "field": "first_name"
> },
> "target": "firstname"
> },
> {
> "source": {
> "model_id": "YOUR-POSTGRES-MODEL-ID",
> "field": "last_name"
> },
> "target": "lastname"
> },
> {
> "source": {
> "model_id": "YOUR-AIRTABLE-MODEL-ID",
> "field": "fldah5pg1Q9k3PmEH"
> },
> "target": "kloutscoregeneral"
> },
> {
> "source": {
> "model_id": "YOUR-STRIPE-MODEL-ID",
> "field": "description"
> },
> "target": "subscription_plan"
> }
> ],
> "schedule": {
> "frequency": "continuous"
> },
> "identity": {
> "source": {
> "model_id": "YOUR-POSTGRES-MODEL-ID",
> "field": "email"
> },
> "target": "email",
> "function": "Equality"
> },
> "target": {
> "connection_id": "YOUR-HUBSPOT-CONNECTION-ID",
> "object": "contacts"
> }
>}'