Syncing contacts from Google Cloud Storage to webhooks

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 webhook Connection.
  2. Create a Google Cloud Storage Connection.
  3. Verify the Connection is ready.
  4. Create a model over a Google Cloud Storage CSV file.
  5. Sync the model to your webhook.

1. Create a webhook Connection

Create the webhook Connection through Polytomic Connect’s embedded authentication or the Create Connection endpoint. See the webhook configuration reference for the required fields.

2. Create a Google Cloud Storage Connection

The following request creates a Google Cloud Storage Connection.

curl --request POST \
--url https://app.polytomic.com/api/connections \
--header "accept: application/json" \
--header "content-type: application/json" \
--header "X-Polytomic-Version: 2025-09-18" \
--header "Authorization: Bearer ${POLYTOMIC_API_KEY}" \
-d '{"name": "Google Cloud Storage Connection","type": "gcs", "configuration": { "service_account": "${GOOGLE_SERVICE_ACCOUNT_JSON_KEY}", "bucket": "gcs://mybucket/mypath"}}'

3. Verify Connection readiness

Before syncing, poll the Get Schema Status endpoint for your Google Cloud Storage Connection ID until cache_status is true. Once it is, the Connection is ready to use.

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 --request POST \
--url https://app.polytomic.com/api/models \
--header "accept: application/json" \
--header "content-type: application/json" \
--header "X-Polytomic-Version: 2025-09-18" \
--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 the webhook

The sync sends email, first_name, and last_name from the GCS model to the webhook. Add more entries to the fields array to sync additional columns.

Create the sync with the Create Sync endpoint:

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": "Sync GCS to Webhook",
"active": true,
"mode": "updateOrCreate",
"fields": [
{
"source": {
"field": "email_address",
"model_id": "YOUR_MODEL_ID"
},
"target": "record"
},
{
"source": {
"field": "first_name",
"model_id": "YOUR_MODEL_ID"
},
"target": "record"
},
{
"source": {
"field": "last_name",
"model_id": "YOUR_MODEL_ID"
},
"target": "record"
}
],
"target": {
"connection_id": "YOUR_WEBHOOK_CONNECTION_ID",
"object": "http",
"configuration": {
"batch_size": 100,
"record_requests": true
}
},
"schedule": {
"frequency": "manual"
}
}'

This example uses a manual schedule, so the sync runs only when you trigger it. Use a manual schedule when you drive syncs from your own orchestration. To run the sync on a recurring schedule instead, set a different schedule frequency.