> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Connect to your users’ Hubspot CRM to create, access, and update records in their Hubspot account.

### Pre-requisites

1. HubSpot Developer Account.
2. Required Settings for the App. You can find it in [Overview](https://docs.gocobalt.io/resources/integration-providers/hubspot_overview#required-settings).

#### Acquiring Hubspot client credentials

1. Login to your [Hubspot Developer account dashboard](https://developers.hubspot.com/).
2. Select `Manage Apps`, and choose from the applications that you'd like your end customers to install.
3. Go to `Basic info` > `Auth` > `Auth settings` > `App Credentials` and acquire the `Client Id` and `Client Secret`.

#### Adding Redirect URL in the Hubspot developer app

While creating an installable app on a platform, the platform asks the developer to provide a redirect URL which it would be calling to send across the authorization code once a
user installs the application.

Select Hubspot from `Apps` and copy the Callback URL provided in the app settings page. Under `Auth` > `Auth Settings` > `Redirect URLs`, paste the copied URL.

<img height="200" src="https://mintcdn.com/cobalt-55/lcADCqUGrbz-iIZQ/images/Hubspot/hubspot-dev-app-setting.png?fit=max&auto=format&n=lcADCqUGrbz-iIZQ&q=85&s=b31f97906718e253389e02eef32255c4" alt="Setting up hubspot developer app" data-path="images/Hubspot/hubspot-dev-app-setting.png" />

#### Configuring credentials in Refold

App settings page lets you configure the authentication settings for an `OAuth2` based application. For your customers to provide you authorization to access their data,
they would first need to install your application. This page lets you set up your application credentials.

<img height="200" src="https://mintcdn.com/cobalt-55/lcADCqUGrbz-iIZQ/images/Hubspot/app_setting.png?fit=max&auto=format&n=lcADCqUGrbz-iIZQ&q=85&s=2cce0c22b44a935a4f5de82171941060" alt="Setting up application client credentials" data-path="images/Hubspot/app_setting.png" />

Provide the acquired Client ID and Client Secret under Settings of the app and save it.

#### Configuring Scopes

Refold lets you configure what permissions to ask from your users while they install your application. The scopes can be added or removed from the App settings page, under `Permissions & Scopes`
section.

For some applications Refold sets mandatory scopes which cannot be removed. Additional scopes can be selected from the drop down. Refold also has the provision to add any
custom scopes supported by the respective platform.

<img height="200" src="https://mintcdn.com/cobalt-55/lcADCqUGrbz-iIZQ/images/Hubspot/Hubspot_scopes.png?fit=max&auto=format&n=lcADCqUGrbz-iIZQ&q=85&s=511fb9dfde77e0a3e6427c44fb8b654b" alt="OAuth Scopes" data-path="images/Hubspot/Hubspot_scopes.png" />

Once the scopes has been added to the application in Refold, go to your [Hubspot Developer account](https://developers.hubspot.com/) dashboard and update the scopes as added on Refold.

Go to  `Manage Apps` > `Basic info` > `Auth` > `Auth settings` > `Scopes`, and add the scopes as added in Refold.

<Warning>
  If you are facing scopes missing or invalid scope error. Make sure you are not passing any custom scope not supported by the platform. And, the scopes selected here are
  identical to the ones selected in the platform.
</Warning>

#### Hubspot Single Webhook URL

If you wish to create an orchestration where a workflow is being triggered when some operation occurs in Hubspot, you'd need to subscribe to Hubspot's Webhook. Refold provides
a single webhook URL to manage such event triggers for all your customers.

**To setup Hubspot webhook subscription:**

1. Select **Hubspot** from the application list in **Refold**, and select `Settings`.
2. Copy the `Single Webhook Url`.
3. Go to `Manage Apps` > `Features` > `Webhooks` in your [Hubspot Developer Account dashboard](https://developers.hubspot.com/).
4. Paste the `Single Webhook Url` inside the "Target URL" section.

<Info>
  Existing `Target URL` cannot be updated when any of the subscriptions are active. Make sure to disable all subscriptions prior to updating the URL.
</Info>

5. Click on `Create Subscription` and add relevant events when you'd want to be notified.

<img height="200" src="https://mintcdn.com/cobalt-55/lcADCqUGrbz-iIZQ/images/Hubspot/hubspot-target-url.png?fit=max&auto=format&n=lcADCqUGrbz-iIZQ&q=85&s=c666d86351c47e5f226e849531124d2e" alt="Setting up HubSpot Target URL" data-path="images/Hubspot/hubspot-target-url.png" />

6. Click on the newly created subscription and `Activate` it to take effect.
