> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://apidocs.polytomic.com/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server. ## UI demo video Watch the same steps in the Polytomic admin console in this [demo video](https://www.loom.com/share/95b169eafc9f4573a581c0dc7b9af5c1?sid=1d05c7a6-a7d7-4286-8e06-a8b8cbf77db3). ## Code Set your Polytomic API key as an environment variable: ```bash export POLYTOMIC_API_KEY=YOUR-API-TOKEN ``` This example covers six steps: 1. Create a Snowflake Connection. 2. Create a Salesloft Connection. 3. Create a Snowflake model over a custom SQL query. 4. List the available Salesloft cadences. 5. List the target fields on a specific cadence. 6. Sync users from Snowflake into a Salesloft cadence. ## 1. Create a Snowflake connection The Snowflake instance must be reachable from Polytomic over the network. See the [Polytomic IP allowlist](/guides/ip-whitelisting) for the source addresses to allow. #### cURL ```bash 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": "Snowflake Connection", "type": "snowflake", "configuration": { "account": "uc193736182", "username": "user", "password": "secret", "dbname": "database" } }' ``` #### Python ```python import os from polytomic.client import Polytomic client = Polytomic( token=os.getenv("POLYTOMIC_API_KEY"), ) resp = client.connections.create( name="Snowflake Connection", type="snowflake", configuration={ "account": "uc193736182", "username": "user", "password": "secret", "dbname": "database" } ) print(resp.data) ``` #### Typescript ```typescript import { PolytomicClient } from 'polytomic'; const polytomic = new PolytomicClient({ token: "POLYTOMIC_API_KEY", }); polytomic.connections.create({ name: "Snowflake Connection", type: "snowflake", configuration: { account: "uc193736182", username: "user", password: "secret", dbname: "database" }, }).then((res) => { console.log(res) }) ``` #### Go ```golang import ( "context" "fmt" polytomic "github.com/polytomic/polytomic-go" polytomicgoclient "github.com/polytomic/polytomic-go/client" "github.com/polytomic/polytomic-go/option" ) client := polytomicgoclient.NewClient( option.WithToken(os.Getenv("POLYTOMIC_API_TOKEN")), ) resp, err := client.Connections.Create( context.TODO(), &polytomic.CreateConnectionRequestSchema{ Name: "Snowflake Connection", Type: "snowflake", Configuration: map[string]interface{}{ "account": "uc193736182", "username": "user", "password": "secret", "dbname": "database", }, }, ) if err != nil { panic(err) } fmt.Println(resp) ``` ## 2. Create a Salesloft connection The following request creates a Salesloft Connection that authenticates through Polytomic Connect's [embedded OAuth modal](/guides/embedding-authentication). You can also connect with a Salesloft API key or run OAuth yourself and pass the client credentials to Polytomic — see the [Salesloft connection configuration](/guides/configuring-your-connections/connections/salesloft) for details. #### cURL ```bash 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": "My Salesloft Connection","type": "salesloft", "configuration": {"auth_method": "oauth"}}' ``` #### Python ```python import os from polytomic.client import Polytomic client = Polytomic( token=os.getenv("POLYTOMIC_API_KEY"), ) resp = client.connections.create( name="My Salesloft Connection", type="salesloft", configuration={ "auth_method": "oauth" } ) print(resp.data) ``` #### Typescript ```typescript import { PolytomicClient } from 'polytomic'; const polytomic = new PolytomicClient({ token: "POLYTOMIC_API_KEY", }); polytomic.connections.create({ name: "My Salesloft Connection", type: "salesloft", configuration: { auth_method: "oauth" }, }).then((res) => { console.log(res) }) ``` #### Go ```golang import ( "context" "fmt" polytomic "github.com/polytomic/polytomic-go" polytomicgoclient "github.com/polytomic/polytomic-go/client" "github.com/polytomic/polytomic-go/option" ) client := polytomicgoclient.NewClient( option.WithToken(os.Getenv("POLYTOMIC_API_TOKEN")), ) resp, err := client.Connections.Create( context.TODO(), &polytomic.CreateConnectionRequestSchema{ Name: "My Salesloft Connection", Type: "salesloft", Configuration: map[string]interface{}{ "auth_method": "oauth", }, }, ) if err != nil { panic(err) } fmt.Println(resp) ``` If you authenticate to Salesloft with OAuth instead of an API key, 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. ## 3. Create a Snowflake model The following request creates a model over a Snowflake query. Replace the query with your own: #### cURL ```bash 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": "Active Users", "configuration": { "query": "SELECT MAX(last_activity_date) AS last_activity_date, plan, first_name, last_name, email FROM users GROUP BY plan, first_name, last_name, email", }, "connection_id": "YOUR-SNOWFLAKE-CONNECTION-ID" }' ``` #### Python ```python import os from polytomic.client import Polytomic client = Polytomic( token=os.getenv("POLYTOMIC_API_KEY"), ) resp = client.models.create( name="Active Users", configuration={ "query": "SELECT MAX(last_activity_date) AS last_activity_date, plan, first_name, last_name, email FROM users GROUP BY plan, first_name, last_name, email", }, connection_id="YOUR-SNOWFLAKE-CONNECTION-ID" ) print(resp.data) ``` #### Typescript ```typescript import { PolytomicClient } from 'polytomic'; const polytomic = new PolytomicClient({ token: "POLYTOMIC_API_KEY", }); polytomic.models.create({ name: "Active Users", configuration: { query: "SELECT MAX(last_activity_date) AS last_activity_date, plan, first_name, last_name, email FROM users GROUP BY plan, first_name, last_name, email", }, connection_id: "YOUR-SNOWFLAKE-CONNECTION-ID", }).then((res) => { console.log(res) }) ``` #### Go ```golang import ( "context" "fmt" polytomic "github.com/polytomic/polytomic-go" polytomicgoclient "github.com/polytomic/polytomic-go/client" "github.com/polytomic/polytomic-go/option" ) client := polytomicgoclient.NewClient( option.WithToken(os.Getenv("POLYTOMIC_API_TOKEN")), ) resp, err := client.Models.Create( context.TODO(), &polytomic.CreateModelRequest{ Name: "Active Users", Configuration: map[string]interface{}{ "query": "SELECT MAX(last_activity_date) AS last_activity_date, plan, first_name, last_name, email FROM users GROUP BY plan, first_name, last_name, email", }, ConnectionId: "YOUR-SNOWFLAKE-CONNECTION-ID", }, ) if err != nil { panic(err) } fmt.Println(resp) ``` ## 4. List the Salesloft target objects Polytomic can sync to Salesloft Accounts, People, and Cadences. Every Salesloft cadence appears as a target object alongside Accounts and People: #### cURL ```bash curl --request POST \ --url https://app.polytomic.com/api/connections/YOUR_SALESLOFT_CONNECTION_ID/modelsync/targetobjects \ --header "accept: application/json" \ --header "content-type: application/json" \ --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" ``` #### Python ```python import os from polytomic.client import Polytomic client = Polytomic( token=os.getenv("POLYTOMIC_API_KEY"), ) resp = client.model_sync.get_target_objects( id="YOUR_SALESLOFT_CONNECTION_ID", ) print(resp.data) ``` #### Typescript ```typescript import { PolytomicClient } from 'polytomic'; const polytomic = new PolytomicClient({ token: "POLYTOMIC_API_KEY", }); polytomic.modelSync.getTargetObjects( "YOUR_SALESLOFT_CONNECTION_ID" ).then((resp) => { console.log(resp); }) ``` #### Go ```golang import ( "context" "fmt" polytomic "github.com/polytomic/polytomic-go" polytomicgoclient "github.com/polytomic/polytomic-go/client" "github.com/polytomic/polytomic-go/option" ) client := polytomicgoclient.NewClient( option.WithToken(os.Getenv("POLYTOMIC_API_TOKEN")), ) resp, err := client.ModelSync.GetTargetObjects( context.TODO(), "YOUR_SALESLOFT_CONNECTION_ID", ) if err != nil { panic(err) } fmt.Println(resp) ``` ## 5. List the target fields on a Salesloft cadence Call the Get Sync Target Fields endpoint to list the target fields available on the cadence you plan to sync to. The fields you map in Step 6 come from this set: #### cURL ```bash curl -G \ --url https://app.polytomic.com/api/connections/YOUR_SALESLOFT_CONNECTION_ID/modelsync/target/fields \ --header "accept: application/json" \ --header "content-type: application/json" \ --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \ --url-query "target=YOUR_SALESLOFT_CADENCE_ID" ``` #### Python ```python import os from polytomic.client import Polytomic client = Polytomic( token=os.getenv("POLYTOMIC_API_KEY"), ) resp = client.model_sync.get_target_fields( id="YOUR_SALESLOFT_CONNECTION_ID", target="YOUR_SALESLOFT_CADENCE_ID" ) print(resp.data) ``` #### Typescript ```typescript import { PolytomicClient } from 'polytomic'; const client = new PolytomicClient({ token: "POLYTOMIC_API_KEY", }); polytomic.modelSync.getTargetFields("YOUR_SALESLOFT_CONNECTION_ID", { target: "YOUR_SALESLOFT_CADENCE_ID }).then((resp) => { console.log(resp); }) ``` #### Go ```golang import ( option "github.com/polytomic/polytomic-go/option" polytomicgo "github.com/polytomic/polytomic-go" polytomicgoclient "github.com/polytomic/polytomic-go/client" "context" "fmt" ) client := polytomicgoclient.NewClient( option.WithToken("POLYTOMIC_API_KEY"), ) response, err := client.ModelSync.GetTargetFields( context.TODO(), "YOUR_SALESLOFT_CONNECTION_ID", &polytomicgo.ModelSyncGetTargetFieldsRequest{ Target: "YOUR_SALESLOFT_CADENCE_ID" }, ) if err != nil { panic(err) } fmt.Println(resp) ``` ## 6. Sync Snowflake users into a Salesloft cadence This sync matches existing Salesloft Person records on `email` and also syncs `first_name` and `last_name` from Snowflake. If a Person does not exist in Salesloft, Polytomic creates it before adding it to the cadence. If it does exist, Polytomic updates it with the mapped field values before adding it. Specify the target cadence with `target.object`: #### cURL ```bash curl --request POST \ --url https://app.polytomic.com/api/syncs \ --header "accept: application/json" \ --header "content-type: application/json" \ --header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \ -d '{ "name": "Snowflake to Salesloft Cadence Sync", "mode": "updateOrCreate", "identity": { "source": { "field": "email", "model_id": "YOUR_SNOWFLAKE_MODEL_ID" }, "target": "Email", "function": "equality" }, "fields": [ { "source": { "field": "first_name", "model_id": "YOUR_SNOWFLAKE_MODEL_ID" }, "target": "FirstName" }, { "source": { "field": "last_name", "model_id": "YOUR_SNOWFLAKE_MODEL_ID" }, "target": "LastName" } ], "schedule": { "frequency": "manual" }, "target": { "connection_id": "YOUR_SALESLOFT_CONNECTION_ID", "object": "my-salesloft-cadence" } }' ``` #### Python ```python import os from polytomic.client import Polytomic from polytomic import ModelSyncField, Source, Identity, Schedule, ScheduleFrequency, Target client = Polytomic( token=os.getenv("POLYTOMIC_API_KEY"), ) resp = client.model_sync.create( name="Snowflake to Salesloft Cadence Sync", mode="updateOrCreate",p identity=Identity( source=Source( field= "email", model_id= "YOUR_SNOWFLAKE_MODEL_ID" ), target="Email", function="equality" ), fields=[ ModelSyncField( source=Source( field="first_name", model_id="YOUR_SNOWFLAKE_MODEL_ID" ), target="FirstName", ), ModelSyncField( source=Source( field="last_name", model_id="YOUR_SNOWFLAKE_MODEL_ID" ), target="LastName", ), ], schedule=Schedule( frequency=ScheduleFrequency.MANUAL, ), target=Target( connection_id="YOUR_SALESLOFT_CONNECTION_ID", object="my-salesloft-cadence" ) ) print(resp.data) ``` #### Typescript ```typescript import { Polytomic, PolytomicClient } from 'polytomic'; const polytomic = new PolytomicClient({ token: "POLYTOMIC_API_KEY", }); polytomic.modelSync.create({ name: "Snowflake to Salesloft Cadence Sync", mode: "create", identity: { source: { field: "email", model_id: "YOUR_SNOWFLAKE_MODEL_ID" }, target: "Email", function: "equality" }, fields: [ { source: { field: "first_name", model_id: "YOUR_SNOWFLAKE_MODEL_ID" }, target: "FirstName" }, { source: { field: "last_name", model_id: "YOUR_SNOWFLAKE_MODEL_ID" }, target: "LastName" } ], schedule: { frequency: Polytomic.ScheduleFrequency.Continuous }, target: { connection_id: "YOUR_SALESLOFT_CONNECTION_ID", object: "my-salesloft-cadence" } }).then((resp) => { console.log(resp); }) ``` #### Go ```golang import ( "context" "fmt" polytomic "github.com/polytomic/polytomic-go" polytomicgoclient "github.com/polytomic/polytomic-go/client" "github.com/polytomic/polytomic-go/option" ) client := polytomicgoclient.NewClient( option.WithToken(os.Getenv("POLYTOMIC_API_TOKEN")), ) resp, err := client.ModelSync.Create( context.TODO(), &polytomic.CreateModelSyncRequest{ Name: "Snowflake to Salesloft Cadence Sync", Identity: &polytomic.Identity{ Source: &polytomic.Source{ Field: "email", ModelId: "YOUR_SNOWFLAKE_MODEL_ID", }, Target: "Email", Function: "Equality", }, Fields: []*polytomic.ModelSyncField{ { Source: &polytomic.Source{ Field: "first_name", ModelId: "YOUR_SNOWFLAKE_MODEL_ID", }, Target: "FirstName", }, { Source: &polytomic.Source{ Field: "last_name", ModelId: "YOUR_SNOWFLAKE_MODEL_ID", }, Target: "LastName", }, }, Schedule: &polytomic.Schedule{ Frequency: pointer.ToString(string(polytomic.ScheduleFrequencyManual)), }, Target: &polytomic.Target{ ConnectionId: "YOUR_SALESLOFT_CONNECTION_ID", Object: "my-salesloft-cadence", }, }, ) if err != nil { panic(err) } fmt.Println(resp) ```