Skip to content

HubSpot Source

The HubSpot source syncs CRM objects, engagements, associations, owners and the legacy v1 email-event and form-submission APIs.

The HubSpot source ships with the core package; no extra is needed.

Terminal window
pip install bizon
name: hubspot-pipeline
source:
name: hubspot
stream: contacts
sync_mode: full_refresh
authentication:
type: api_key
params:
token: ${env://HUBSPOT_TOKEN}
destination:
name: bigquery
config:
project_id: my-project
dataset_id: crm
gcs_buffer_bucket: my-bucket
Terminal window
bizon stream list hubspot
StreamSync modesNotes
contacts, companies, dealsfull refresh, incrementalv3 list API. Incremental goes through the search API on the last-modified property (cursor_field overrides it)
custom_objectfull refresh, incrementalSame as above for the object set by object_type (e.g. 2-1234567)
contacts_search, companies_search, deals_searchfull refresh, incrementalSearch API only, with start_date, page_size (max 200) and full_scan
engagements_emailsfull refresh, incrementalSearch on hs_lastmodifieddate, plus associated contact/company/deal/ticket ids
engagements_notes, engagements_calls, engagements_tasks, engagements_meetingsfull refreshInline contact/company/deal associations, paged past HubSpot’s 100 per type
line_items, deal_pipelines, properties_contacts, properties_companies, properties_dealsfull refresh
ownersfull refreshActive then archived owners; the record id is <id>:<active|archived>
archived_contacts, archived_deals, archived_companiesfull refresh, incrementalWhole archived list filtered on archivedAt; use incremental to accumulate history
association_deals, association_new_contactsfull refreshv4 associations, one row per (id, associated id, association type)
contacts_merged_auditfull refreshMerged contacts with their v1 merge-audit trail
email_events, form_submissionsfull refresh, incrementalv1 APIs, re-reading the last 6 hours on each incremental run

Search-based streams page by hs_object_id rather than the search after cursor, so they are not capped at HubSpot’s 10,000 search results. Their window ends at the job’s start time, so consecutive incremental runs tile.

FieldDefaultDescription
properties.strategyallall fetches the whole property catalog; selected sends properties.selected_properties, which must exist
properties.selected_properties[]Properties to fetch with strategy: selected
start_dateunsetISO-8601 lower bound for a full refresh or a first incremental run, on streams that take it (*_search, engagements_emails, archived_*, email_events, form_submissions). Unset fetches everything
max_requests_per_secondunsetClient-side pacing across every call of a run (must be > 0). Set it when other clients share the app’s rate budget: search endpoints are rate limited per account and send no rate-limit headers
object_type-Object type id for the custom_object stream
associations_types[]Object types whose associated ids are inlined on contacts/companies/deals/custom_object records. Full refresh only
page_size200Search page size on *_search streams (max 200)
full_scanfalseOn *_search streams, ignore the date window and re-fetch every record on every run
http50 retries, backoff 1, (10, 60) timeoutHTTP policy. A partial block is merged over this default

HubSpot supports a private app token or OAuth.

Private app token:

source:
name: hubspot
stream: contacts
authentication:
type: api_key
params:
token: ${env://HUBSPOT_TOKEN}

To get your token:

  1. Go to HubSpot Settings > Integrations > Private Apps
  2. Create a new private app
  3. Grant required scopes (crm.objects.contacts.read, etc.)
  4. Copy the access token

OAuth:

source:
name: hubspot
stream: contacts
authentication:
type: oauth
params:
token_refresh_endpoint: https://api.hubapi.com/oauth/v1/token
client_id: ${env://HUBSPOT_CLIENT_ID}
client_secret: ${env://HUBSPOT_CLIENT_SECRET}
refresh_token: ${env://HUBSPOT_REFRESH_TOKEN}

The access token is refreshed 120 seconds before it expires (set params.expiry_skew_seconds to change this). A request rejected with 401 EXPIRED_AUTHENTICATION mid-run forces a refresh and is replayed once.

Syncs all records from scratch:

source:
name: hubspot
stream: contacts
sync_mode: full_refresh

Syncs records modified since the last successful run:

source:
name: hubspot
stream: contacts
sync_mode: incremental

On contacts, companies, deals and custom_object, an incremental run searches on the last-modified property (lastmodifieddate for contacts, hs_lastmodifieddate otherwise) from last_run minus a 5-minute overlap up to the job’s start time. Duplicates from the overlap share the record id. The first run fetches everything.

name: hubspot-contacts
source:
name: hubspot
stream: contacts
sync_mode: incremental
authentication:
type: api_key
params:
token: ${env://HUBSPOT_TOKEN}
destination:
name: bigquery
config:
project_id: my-project
dataset_id: crm
dataset_location: US
gcs_buffer_bucket: my-staging-bucket
unnest: true
record_schemas:
- destination_id: my-project.crm.contacts
record_schema:
- name: id
type: STRING
mode: REQUIRED
- name: email
type: STRING
mode: NULLABLE
- name: firstname
type: STRING
mode: NULLABLE
- name: lastname
type: STRING
mode: NULLABLE
- name: createdate
type: TIMESTAMP
mode: NULLABLE
- name: lastmodifieddate
type: TIMESTAMP
mode: NULLABLE
name: hubspot-deals-search
source:
name: hubspot
stream: deals_search
sync_mode: incremental
start_date: "2025-01-01T00:00:00Z"
max_requests_per_second: 5
authentication:
type: oauth
params:
token_refresh_endpoint: https://api.hubapi.com/oauth/v1/token
client_id: ${env://HUBSPOT_CLIENT_ID}
client_secret: ${env://HUBSPOT_CLIENT_SECRET}
refresh_token: ${env://HUBSPOT_REFRESH_TOKEN}
destination:
name: bigquery
config:
project_id: my-project
dataset_id: crm
gcs_buffer_bucket: my-staging-bucket
source:
name: hubspot
stream: custom_object
object_type: "2-1234567" # from GET /crm/v3/schemas
associations_types:
- companies
- contacts
authentication:
type: api_key
params:
token: ${env://HUBSPOT_TOKEN}

Run separate pipelines for each stream:

Terminal window
bizon run contacts.yml
bizon run companies.yml
bizon run deals.yml

Retries on 429 and 5xx are handled by the session, using HubSpot’s default of 50 retries with a backoff factor of 1. Tune them with source.http:

source:
name: hubspot
stream: contacts
max_requests_per_second: 5
http:
retries:
total: 20

HubSpot object records include:

FieldDescription
idHubSpot object ID
propertiesObject properties (email, name, etc.)
createdAtRecord creation timestamp
updatedAtLast modification timestamp
archivedWhether record is archived

Flatten HubSpot properties:

transforms:
- label: flatten-properties
python: |
props = data.get('properties', {})
data = {
'id': data.get('id'),
'email': props.get('email'),
'firstname': props.get('firstname'),
'lastname': props.get('lastname'),
'company': props.get('company'),
'created_at': data.get('createdAt'),
'updated_at': data.get('updatedAt')
}