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
  • Code
  • 1. Create a Salesforce connection
  • 2. Create a Google Cloud Storage connection
  • 3. Verify connection readiness
  • 4. Create a source model over the GCS CSV
  • 5. Sync the GCS model to Salesforce Contacts
  • Listing target objects
  • Creating the sync
Code examples

Syncing contacts from Google Cloud Storage to Salesforce

Was this page helpful?
Previous

Syncing contacts from Google Cloud Storage to webhooks

Next

Code

Set your Polytomic API key as an environment variable:

$export POLYTOMIC_API_KEY=YOUR-API-TOKEN

This example covers five steps:

  1. Create a Salesforce connection.
  2. Create a Google Cloud Storage connection.
  3. Verify the connections are ready.
  4. Create a model over a Google Cloud Storage CSV file.
  5. Sync the model to Salesforce Contacts.

1. Create a Salesforce connection

The following request creates a Salesforce Connection through the Create Connection endpoint. For end-user onboarding, prefer Polytomic Connect’s embedded auth.

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": "Salesforce Connection","type": "salesforce", "configuration": {"domain": "https://example.my.salesforce.com"}}'

Salesforce 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.

2. Create a Google Cloud Storage connection

The following request creates a Google Cloud Storage Connection.

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": "Google Cloud Storage Connection","type": "gcs", "configuration": { "service_account": "service_account_json_key", "bucket": "gcs://mybucket/mypath"}}'

3. Verify connection readiness

Before syncing, poll the Get Schema Status endpoint for each Connection ID until cache_status is true. Once it is, the Connection’s schema is ready to query.

4. Create a source model over the GCS CSV

Next, create a model over a CSV file in Google Cloud Storage (GCS). A model is a view — a collection of fields you can sync to other systems in whole or in part.

Call the Create Model endpoint to expose every column in high_paying_users.csv:

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": "GCS Contacts",
> "configuration": {
> "model_from": "single_file",
> "key": "high_paying_users.csv"
> },
> "connection_id": "YOUR_GCS_CONNECTION_ID"
> }'

5. Sync the GCS model to Salesforce Contacts

The sync maps email on the GCS model to the Email field on Salesforce Contacts, and also maps first_name and last_name. Add more entries to the fields array to sync additional columns.

Listing target objects

To discover the target objects available on a destination, use the Get Sync Target Objects endpoint.

Creating the sync

Create the sync with the Create Sync endpoint.

cURL
Python
Typescript
Go
$curl --request POST \
> --url https://app.polytomic.com/api/syncs \
> --header "accept: application/json" \
> --header "content-type: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
> -d '{
> "name": "GCS to Salesforce Sync",
> "mode": "updateOrCreate",
> "identity": {
> "source": {
> "field": "email",
> "model_id": "YOUR_MODEL_ID"
> },
> "target": "Email",
> "function": "equality"
> },
> "fields": [
> {
> "source": {
> "field": "first_name",
> "model_id": "YOUR_MODEL_ID"
> },
> "target": "FirstName"
> },
> {
> "source": {
> "field": "last_name",
> "model_id": "YOUR_MODEL_ID"
> },
> "target": "LastName"
> }
> ],
> "schedule": {
> "frequency": "Manual"
> },
> "target": {
> "connection_id": "YOUR_SALESFORCE_CONNECTION_ID",
> "object": "Contact"
> }
> }'