Skip to main content
Skip table of contents

HubSpot API [REST Custom]

PocketQuery allows you to connect directly to HubSpot’s REST API and query your CRM data with a wide range of objects, such as Contacts, Companies, Deals, and Discounts. You can use PocketQuery to fetch, filter, and explore this data just like any other data source.

In the examples below, we’ll demonstrate how to connect to the Contacts API. The same approach works for any other HubSpot object - simply adjust the endpoint URL accordingly. For detailed information on available endpoints and object types, refer to the HubSpot CRM API documentation - all available objects are listed in the sidebar.

Preview

Bildschirmfoto 2025-09-26 um 15.48.02.png

Step 1: Create a private app in HubSpot

  1. Sign into HubSpot as a Super admin.

  2. In your HubSpot account, navigate to Development.

  3. In the left sidebar menu, navigate to Legacy apps.

  4. In the top right, click Create:

    Screenshot of HubSpot Development Settings
  5. In the dialog box, select Private:

    Screenshot of Hubspot Dialog Box
  6. Give the app a name, logo and short description (optional):

    HubSpot Screen for setting up a private app

Step 2: Choose scopes/permissions

  1. Click the Scopes tab.

  2. At the top of the page, click Add new scope:

    Screenshot of HubSpot scope settings
  3. In the right panel, select the checkbox for each scope you want your private app to be able to access. In our example, wanting to read contacts, add:

  • crm.objects.contacts.read

    Screenshot of HubSpot settings - adding a new scope

If you want Companies / Deals / etc, add:

  • crm.objects.companies.read, crm.objects.deals.read, ...

  1. After you’ve chosen your scopes, click Create app:

Screenshot of HubSpot Create app button

Step 3: Get your access token

  1. After you finish creating it, HubSpot will redirect you to the app overview (Development → Legacy apps → name of your app).

  2. Go to the Auth tab.

  3. Inside the Access Token box, click Show token.

  4. …and then Copy:

    Screenshot of HubSpot app Auth overview

Step 4: Create a Datasource in PocketQuery

Open PocketQuery Administration → Datasources, and create a new REST datasource:

Field

Value

Name

HubSpot [REST Custom]

Type

REST Custom

Base URL

https://api.hubapi.com/

Test path

crm/v3/objects/contacts

Request Headers (left field)

Authorization

Request Headers (right field)

Bearer <your-access-token>

(replace “<your-access-token>” with the access token you copied in Step 3)

You can now test your connection by clicking the Test connection link at the bottom. If everything works as expected, click Create Datasource.

Step 5: Create a Converter in PocketQuery

Go to PocketQuery Administration → Converter, and create a new Converter. This will display your result data in a neat table:

CODE
function convert(json) {
  const data = JSON.parse(json);

    return data.results.map(contact => {
	return {
	  'E-Mail': contact.properties.email,
	  'First name': contact.properties.firstname,
	  'Last name': contact.properties.lastname,
	  'Created at': contact.properties.createdate,
	};
  });
}

Step 6: Create a Query in PocketQuery

Go to PocketQuery Administration → Queries, and create a new Query that fetches your contacts.

Field

Value

Name

HubSpot Contacts

Datasource

HubSpot [REST Custom]

REST URL

crm/v3/objects/contacts

That’s it! After clicking Save Query, you can test your query in the Query Preview and use it on any Confluence Page with the PocketQuery Macro:

Bildschirmfoto 2025-09-26 um 15.48.02.png

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.