Skip to main content
This documentation describes the integration of MindsDB with HubSpot. The HubSpot handler for MindsDB provides interfaces to connect to HubSpot via APIs and pull store data into MindsDB. HubSpot is a comprehensive CRM platform providing marketing, sales, content management, and customer service tools. This integration exposes HubSpot CRM data through MindsDB’s SQL interface.

Prerequisites

Before proceeding, ensure the following prerequisites are met:
  1. Install MindsDB locally via Docker or Docker Desktop.
  2. To connect HubSpot to MindsDB, install the required dependencies following this instruction.

Authentication

The handler supports two authentication methods:

Personal Access Token Authentication

Recommended for server-to-server integrations and production environments. Steps to obtain an access token:
  1. Navigate to your HubSpot account settings
  2. Go to Integrations -> Private Apps
  3. Create a new private app or select an existing one
  4. Configure required scopes for the tables you plan to access
  5. Copy the generated access token

OAuth Authentication

Recommended for applications requiring user consent and dynamic scope management. Required OAuth Parameters:
  • client_id: Your app’s client identifier
  • client_secret: Your app’s client secret (store securely)
OAuth token exchange and refresh are handled externally.

Supported Tables

Core CRM and Engagement Tables

These tables support SELECT, INSERT, UPDATE, and DELETE operations.

Metadata Tables

These tables are read-only and support SELECT only.
Table NameDescriptionReference
ownersHubSpot owners with names and emailshttps://developers.hubspot.com/docs/api-reference/crm-owners-v3/guide
pipelinesDeal pipelines with names and stageshttps://developers.hubspot.com/docs/api-reference/crm-pipelines-v3/guide

Association Tables

Association tables are read-only and support SELECT only. They expose relationships between objects and include association_type and association_label columns. Reference: https://developers.hubspot.com/docs/api-reference/crm-associations-v4/guide
Table NameDescription
company_contactsCompany to contact associations
company_dealsCompany to deal associations
company_ticketsCompany to ticket associations
contact_companiesContact to company associations
contact_dealsContact to deal associations
contact_ticketsContact to ticket associations
deal_companiesDeal to company associations
deal_contactsDeal to contact associations
ticket_companiesTicket to company associations
ticket_contactsTicket to contact associations
ticket_dealsTicket to deal associations

Connection

Using Access Token:
CREATE DATABASE hubspot_datasource
WITH ENGINE = 'hubspot',
PARAMETERS = {
  "access_token": "pat-na1-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
};
Using OAuth (Advanced):
CREATE DATABASE hubspot_datasource
WITH ENGINE = 'hubspot',
PARAMETERS = {
  "client_id": "your-client-id",
  "client_secret": "your-client-secret"
};

Usage

Basic Data Retrieval:
SELECT * FROM hubspot_datasource.companies LIMIT 10;
SELECT * FROM hubspot_datasource.contacts LIMIT 10;
SELECT * FROM hubspot_datasource.deals LIMIT 10;
Date Filters (Supported Functions):
SELECT * FROM hubspot_datasource.deals
WHERE closedate >= DATE_SUB(CURRENT_DATE, INTERVAL 2 YEAR);
Creating Records:
INSERT INTO hubspot_datasource.companies (name, domain, industry, city, state)
VALUES ('Acme Corp', 'acme.com', 'COMPUTER_SOFTWARE', 'New York', 'NY');

INSERT INTO hubspot_datasource.contacts (email, firstname, phone)
VALUES ('john.doe@example.com', 'John', '+1234567890');

INSERT INTO hubspot_datasource.tasks (hs_task_subject, hs_task_status)
VALUES ('Follow up with Acme', 'WAITING');
Updating Records:
UPDATE hubspot_datasource.companies
SET industry = 'COMPUTER_SOFTWARE', city = 'Austin'
WHERE name = 'Acme Corp';

UPDATE hubspot_datasource.deals
SET dealstage = '110382973', amount = '75000'
WHERE dealname = 'New Deal';
Deleting Records:
DELETE FROM hubspot_datasource.deals
WHERE dealstage = 'closedlost'
  AND createdate < '2023-01-01';

Notes on Filters and Limits

  • Supported filter operators include =, !=, <, <=, >, >=, IN, and NOT IN.
  • Date helpers supported in filters include CURDATE()/CURRENT_DATE, NOW()/CURRENT_TIMESTAMP, DATE_SUB, and DATE_ADD.
  • Updates and deletes evaluate conditions against a sample of up to 200 records before applying changes.
  • Unsupported filters or order-by expressions are skipped rather than raising errors.