> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/h/hubspot.md).

# HubSpot

HubSpot is a CRM platform. OctoXLabs reads the HubSpot owners from the CRM API and adds them to the user inventory.

## Use cases

* List HubSpot users and compare them with your directory.

```
Adapters = hubspot AND NOT Adapters = active-directory
```

* Find HubSpot users created recently.

```
Adapters = hubspot AND CreatedTime last now-30d/d
```

## Before you begin

### Network

| Source              | Destination      | Port | Protocol |
| ------------------- | ---------------- | ---- | -------- |
| OctoXLabs connector | `api.hubapi.com` | 443  | HTTPS    |

### Required permissions

| Scope or role                                        | Permission                      | Needed for |
| ---------------------------------------------------- | ------------------------------- | ---------- |
| Public app with the scope that allows reading owners | Read owners (`/crm/v3/owners/`) | Users      |

## Create credentials in HubSpot

{% stepper %}
{% step %}

### Create a public app

In your HubSpot developer account create a new **Public App**.
{% endstep %}

{% step %}

### Copy the client credentials

Copy the Client ID and Client Secret from the **Auth** section of the app.
{% endstep %}

{% step %}

### Set the redirect URI

Add your redirect URL in the **Auth** settings of the app.
{% endstep %}

{% step %}

### Install the app

Open the app's **Install URL**. It contains the client ID, the redirect URI and the scopes. Authorize the app.
{% endstep %}

{% step %}

### Copy the code

After you authorize, HubSpot redirects to your redirect URI with a `code` parameter. This is the Authorization Code.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter          | Required | Type    | Default          | Description                                                   |
| ------------------ | -------- | ------- | ---------------- | ------------------------------------------------------------- |
| Domain             | Yes      | Text    | `api.hubapi.com` | HubSpot API host.                                             |
| Authorization Code | Yes      | Text    | None             | Code returned in the redirect URL after the app is installed. |
| Redirect URI       | Yes      | Text    | None             | Redirect URL set in the app.                                  |
| Client ID          | Yes      | Text    | None             | Client ID of the app.                                         |
| Client Secret      | Yes      | Text    | None             | Client secret of the app.                                     |
| Timeout            | No       | Integer | `30`             | Seconds to wait for API responses.                            |

## Troubleshooting

| Error message                                  | Cause                                             | Fix                                                      |
| ---------------------------------------------- | ------------------------------------------------- | -------------------------------------------------------- |
| `Failed to fetch users: <status>`              | The owners call returned a status other than 200. | Check the app scopes and the credentials.                |
| `Request failed after 5 retries for url <url>` | HTTP 401 or 429 persisted.                        | Create a new authorization code and run discovery again. |

## Change history

{% hint style="info" %}
Available starting from version 5.6.6.
{% endhint %}
