<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=262721675103356&amp;ev=PageView&amp;noscript=1">

5 min read

Step-by-step guide how to create and use Private Apps in HubSpot

Step-by-step guide how to create and use Private Apps in HubSpot
8:48

Did you know that you can use the HubSpot API to access very specific data in your account in a secure way? You can do this with HubSpot's Private Apps!

In this article, we'll teach you what Private Apps are, how you can create and use them to personalize your experience on the platform and get the most value from your data in HubSpot.

 

What are Private Apps?

In simple terms, Private Apps are a way to access specific data in a HubSpot account by generating an access token. These apps can only be used by the HubSpot account in which they were created and can only access the data and resources that have been granted to them through the scopes.

The Private Apps came to replace the "API Keys", before, API Key was the way to authenticate your application to use the HubSpot APIs, with this you could access and modify the data of your account. The problem with the API key was that it gave root access to all endpoints. So, if someone obtained that key, they would have access to all the information available through requests, without restrictions.

private-apps-api-keysIn fact, Private Apps are still an authentication mechanism through a token, however, they are different in terms of permissions, since you can limit the actions and the scope of the information to which they have access, for example, if you have an app that only requires reading the information of a contact you can grant only read permissions to contacts end point.

Create a Private App

To create a Private App you must have the corresponding configuration permissions and follow the steps below:

In your HubSpot account, click the settings icon in the main navigation bar.

private-apps-paso-1

In the left sidebar menu, go to Integrations > Private Apps.

private-apps-paso-2

Click the “Create a private app” button.

private-apps-paso-3

In the “Basic Info” tab, configure the details of your application: name, logo and description.

private-apps-paso-4

Now go to tab “Scopes”.

private-apps-paso-5

Here you will have a list with all the permissions that you can grant to your application, these are divided into four categories:

  • CMS
  • CRM
  • Settings
  • Standard

You can see the full scope list on the HubSpot site for more information. Once you have finished configuring your app, click the “Create app” button in the top right corner.

private-apps-paso-6

And that's it, you already have your Private App created! You can start making HubSpot API calls using the access token to get familiar with it.

private-apps-paso-7

 

Edit a Private App

Remember that you can always edit the configuration of your application in case you need to change information or scopes. Just click the “Edit details” button.

private-apps-paso-8

You can also change the access token; in case it is compromised you can rotate the token. A new access token will be created, and the original will expire. Simply click the “Rotate” button located in the “Access token” section of your application.

private-apps-paso-9

If your token is compromised and you want to revoke access immediately, click “Rotate and expire this token now”.

If there is no imminent threat to your token, it is still recommended that you rotate your token every six months. If you are ready to start a regular rotation of your token, click on “Rotate and expire this token later”, which will activate the token expiration in 7 days.

private-apps-paso-10

Delete a Private App

When you delete your Private App, its access token will be permanently revoked and you will no longer be able to use it to make API calls. To delete your app, click the “Delete Private-App” button in the last section of your app details.

private-apps-paso-11

Make API calls through your Private App

With your Private App created and configured, you are ready to make calls to the HubSpot API. Remember that the actions and information you have access to is limited by the permissions you defined.

All you need is the access token that you can check in the details tab of your application, just click on the “Show token” option.

private-apps-paso-12

Ok, now you can begin to carry out tests so that you become familiar with it.

NOTE: To make calls to the HubSpot API you must set the Authorization value in the header like this: “Bearer [YOUR_TOKEN]”. Bearer is a standard form of authentication used to identify an access token in an HTTP request.

Here are some ways you can make HubSpot API calls with your Private App:

Node.js & Axios

You can make a call to the contacts API using Node.js and axios as follows.

private-apps-paso-13

You can even create an instance to define your token just once and use that instance for all requests, like so.

private-apps-paso-14

Postman

You can make API call tests through Postman.

First you must indicate the type of HTTP request and the end point to which you want to make the call, in this case it is a "GET" type request to the "Contacts" end point.

private-apps-paso-15

Then, in the "Headers" tab you must add the "Authorization" key with the value "Bearer [YOUR_TOKEN]" that I previously mentioned.

private-apps-paso-16

Finally, click on the "Send" button, if the request was successful, you can view the information in the "Body" tab.

private-apps-paso-17

HubSpot Developers Site

On the HubSpot developer site you can see all the information about HubSpot APIs such as endpoints.

In this case we are going to access the section CRM > Objects > Contacts located on the left.

private-apps-paso-18

Now click the "Endpoints" tab to see the information of the end points available in the contacts API.

private-apps-paso-19

Here's a complete and detailed list of everything you can do in HubSpot's Contacts API, however that's a topic for another article. For now I want to show you an option to make your API calls.

In each of the end points you can find the "Test call" button located in the upper right corner.

private-apps-paso-20

You just have to select the authentication method “Private app access token” and paste your token. If the request is successful, you can view the call data in the "Response" tab.

private-apps-paso-21

Workflows in HubSpot

The previous ones were examples to practice and experiment with your Private App, however, here I want to give you an approach of how you could use it in the real world. In HubSpot workflows, you can use custom code to write and run custom code that extends the workflow's functionality inside and outside of HubSpot.

private-apps-paso-22

HubSpot makes available a number of libraries that help you perform complex actions more easily, for example, if you're using the Node.js client library, you can instantiate an OAuth client by passing the token from access to your application.

NOTE: Private Apps access tokens are implemented using the OAuth protocol as a base.

private-apps-paso-23

In this way, that instance that you created would already have the access permissions that you granted to your Private App, that is, you can now use the methods that the library offers you to manipulate the information.

Now, if you think about it, including your access token in the lines of a code that can be broken is very dangerous, anyone who gets access to it could steal the token and use it to access your data. But don't worry, there is a solution and that is why I wanted to show you the topic of Private Apps in workflows, HubSpot includes an option called "Secrets" in custom codes.

private-apps-paso-24

HubSpot custom code secrets are used to authenticate and authorize access. These are stored in a protected area and you can access them through environment variables in your custom code. In this way your tokens will be encapsulated in an additional layer of security.

Simply select “Choose a secret” press the “Add secret” option and now give your secret a name and the value that in this case will be the access token of your Private App.

private-apps-paso-25

That’s it! In “Secrets” you can see the list of your secrets and now you can use it in your code. (You can use multiple secrets in the same custom code)

private-apps-paso-26private-apps-paso-27

Here's an example using the HubSpot client library to archive a contact by their ID with the "TEST_SECRET" environment variable.

private-apps-paso-28

 

View API call logs

HubSpot API calls are limited depending on your HubSpot subscription.

private-apps-paso-29

To review the calls to the API that your application has made, you must access the "Logs" tab of your Private App and here you will have a list of the calls with method, response, and period filters.

private-apps-paso-30

In the "Security" tab you will have a list with the date and the user who has manipulated the access token at a certain time.

private-apps-paso-31

HubSpot Private Apps are an ideal solution for businesses that want to improve their efficiency and productivity by using tools that are customized and specific to their needs. These private apps allow users to access their resources and automate tasks, saving valuable time and resources.

When creating a Private App, it is important to consider careful planning as proper security practices must be followed to ensure sensitive data and secrets are protected.

In short, HubSpot Private Apps are a great option for businesses looking to personalize their experience on the HubSpot platform while improving their efficiency and productivity.

Suggested Insights For You

Essential Foundations for Integrating Apps in HubSpot

Essential Foundations for Integrating Apps in HubSpot

Discover the essential fundamentals for integrating apps in HubSpot. Define the step-by-step objectives and parameters of your integration projects.

Read More
Step-by-step guide on how to create tickets in HubSpot

Step-by-step guide on how to create tickets in HubSpot

Discover what HubSpot service tickets are, what they do, and how they automate the service team and improve the customer experience.

Read More
Create a Workflow step by step in HubSpot

Create a Workflow step by step in HubSpot

Find out how to create Workflows step by step within HubSpot, how to set them up, types of workflows, and how they help companies automate processes.

Read More

ICX SUBSCRIPTION

Come and be part of the latest specific insights provided by our experts

What’s next?

ARE YOU READY?