Back
HubSpot Wrapper

HubSpot Wrapper

Overview

HubSpot Wrapper

HubSpot is a unified customer platform covering marketing, sales, content, and service. It gives teams the tools to attract, engage, and retain customers, with a shared CRM at the center connecting data across every team and touchpoint.

The HubSpot Wrapper brings your CRM data into Postgres as queryable foreign tables. Query contacts, companies, deals, tickets, and more with plain SQL and join them against your application data. The wrapper works with Supabase Vault for secure token management and is built on WebAssembly (Wasm) for lightweight, sandboxed execution.

Preparation

Before you get started, make sure the wrappers extension is installed on your database:


_10
create extension if not exists wrappers with schema extensions;

and then enable the Wasm foreign data wrapper:


_10
create foreign data wrapper wasm_wrapper
_10
handler wasm_fdw_handler
_10
validator wasm_fdw_validator;

About authentication

HubSpot deprecated their legacy API keys in November 2022. The api_key option in this wrapper accepts a Private App Access Token, which is HubSpot's recommended authentication method. See HubSpot Private Apps for setup instructions.

Secure your credentials (optional)

By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.


_10
select vault.create_secret(
_10
'<HubSpot access token>',
_10
'hubspot',
_10
'HubSpot private apps access token for Wrappers'
_10
);

Connecting to HubSpot

We need to provide Postgres with the credentials to access HubSpot, and any additional options. We can do this using the create server command:

With Vault (by key ID):


_10
create server hubspot_server
_10
foreign data wrapper wasm_wrapper
_10
options (
_10
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_hubspot_fdw_v0.2.0/hubspot_fdw.wasm',
_10
fdw_package_name 'supabase:hubspot-fdw',
_10
fdw_package_version '0.2.0',
_10
fdw_package_checksum '223f0e8d7557bd24f51b58fb89dcd3c1431719105acca0754ce35dfd1139296a',
_10
api_url 'https://api.hubapi.com/crm/v3',
_10
api_key_id '<key_ID>'
_10
);

With Vault (by key name):


_10
create server hubspot_server
_10
foreign data wrapper wasm_wrapper
_10
options (
_10
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_hubspot_fdw_v0.2.0/hubspot_fdw.wasm',
_10
fdw_package_name 'supabase:hubspot-fdw',
_10
fdw_package_version '0.2.0',
_10
fdw_package_checksum '223f0e8d7557bd24f51b58fb89dcd3c1431719105acca0754ce35dfd1139296a',
_10
api_url 'https://api.hubapi.com/crm/v3',
_10
api_key_name 'hubspot'
_10
);

Without Vault:


_10
create server hubspot_server
_10
foreign data wrapper wasm_wrapper
_10
options (
_10
fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_hubspot_fdw_v0.2.0/hubspot_fdw.wasm',
_10
fdw_package_name 'supabase:hubspot-fdw',
_10
fdw_package_version '0.2.0',
_10
fdw_package_checksum '223f0e8d7557bd24f51b58fb89dcd3c1431719105acca0754ce35dfd1139296a',
_10
api_url 'https://api.hubapi.com/crm/v3',
_10
api_key 'pat-xxx-xxxxxxx-...'
_10
);

Note: the fdw_package_* options are required and specify the Wasm package metadata. See the Available Versions table above for the full list.

Resources

Details

DeveloperSupabase
DocumentationLearn

Third-party integrations and docs are managed by Supabase partners.

Get started with HubSpot Wrapper and Supabase.