Quickstart

This quick start guide illustrates an end-to-end example of setting up a Polytomic sync.

Prerequisites

This guide makes use of cURL, a command line program for making HTTP requests. MacOS and many Linux distributions have cURL pre-installed, and it is also available for download on Windows and many other operating systems. This guide also demonstrates using Polytomic’s native clients.

Setup

Generate an API key in the your user settings panel. For more information, see the authentication section.

Making API Requests

Set the API token as an environment variable:

export POLYTOMIC_API_KEY=YOUR-API-TOKEN

Replace YOUR-API-TOKEN with the token you just generate in the step above.

Make a request to the identity endpoint:

$curl --request GET \
> --url https://app.polytomic.com/api/me \
> --header "accept: application/json" \
> --header "X-Polytomic-Version: 2024-02-08" \
> --header "Authorization: Bearer ${POLYTOMIC_API_KEY}"

1. Create a HubSpot connection

The following request will create a Hubspot connection. The configuration for each type of connection can be found at the connection configuration docs page.

$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": {}}'

Since Hubspot connections uses OAuth to authenticate, we’ll need to follow the link returned in the auth_url parameter in the response

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.

2. Create a PostgreSQL connection

The PostgreSQL server must be network-accessible from Polytomic.

$ 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"
> }
> }'

Source objects may not be immediately readable after creating a connection; Polytomic may take a few moments to cache source schemas after creating a connections.

3. Create a bulk sync

This will create a bulk sync of all Hubspot objects into Postgres:

$curl --request POST \
> --url https://app.polytomic.com/api/bulk/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": "Hubspot Bulk Sync",
> "source_connection_id": "YOUR-HUBSPOT-CONNECTION-ID",
> "destination_connection_id": "YOUR-POSTGRES-CONNECTION-ID",
> "mode": "replicate",
> "schedule": {
> "frequency": "continuous"
> },
> "destination_configuration": {
> "schema": "hubspot"
> },
> "schemas": ["contacts", "companies", "deals"]
> }'