API Connector Documentation
Import GoHighLevel Data to Google Sheets
In this guide, we’ll walk through how to pull data from the GoHighLevel API directly into Google Sheets, using the API Connector add-on.
GoHighLevel has recently introduced a new OAuth-based API, so there are currently 2 ways to connect:
- API token. Tokens are used for the v1 API, which will be deprecated on June 1, 2024.
- OAuth. The v2 API only supports authorization via OAuth.
Contents
- Before You Begin
- Part 1: GoHighLevel's v1 API
- Part 2: GoHighLevel's v2 API
- Part 3: Handle Pagination
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: GoHighLevel's V1 API
1) Get Your GoHighLevel v1 API Token
- Log in to GoHighLevel and click Settings from the menu.
- Scroll down the page and you'll see that an API token has been automatically created for you. Click to copy it to your clipboard. Congrats, you can now access the GoHighLevel API!
2) Pull GoHighLevel v1 API Data into Sheets
For this example, we'll fetch contacts, though you can select any endpoint provided in the v1 documentation. Where it says your_token
, substitute in the token you got from your company settings page.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following:
- Application:
Custom
- Method:
GET
- Request URL:
http://rest.gohighlevel.com/v1/contacts?limit=100
- Headers:
Authorization
:Bearer your_token
- Application:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see your contacts populate your Google Sheet.
Part 2: GoHighLevel's v2 API
The GoHighLevel v2 API uses OAuth, so we'll use API Connector's custom OAuth connection manager.
1) Create a GoHighLevel v2 App
- Navigate to https://developers.gohighlevel.com/, create an account, and log in
- Once you're logged in, click on App Dashboard > +Create App from the top nav
- Fill in your app details and click Create App. Selecting a "Private" app means you don't need to upload brand-related images or go through their approval process.
- From the Settings screen, add all the scopes you'd like to have access to
- Scroll down to the "Redirect URL" section and type in API Connector's redirect URL as provided here.
- Under Client Keys, click +Add
- You'll be prompted to give your key a name (it can be anything). You'll then be presented with your client ID and key. Keep these safe as we'll need them shortly.
- Scroll to the bottom of the page and click Save before navigating away.
2) Connect GoHighLevel v2 to API Connector
- Open up Google Sheets and click Extensions > API Connector > Manage Connections
- Scroll to the bottom of the sidebar and click Add Custom OAuth
- Fill in the Custom OAuth modal as follows, substituting in your own scopes:
- OAuth Grant Type:
Authorization Code
- Name:
Custom HighLevel
- Authorization Base URL:
https://marketplace.leadconnectorhq.com/oauth/chooselocation?scope=contacts.readonly locations.readonly calendars.readonly campaigns.readonly contacts.readonly locations.readonly products.readonly users.readonly
- Token URL:
https://services.leadconnectorhq.com/oauth/token
- Client ID: provided by GoHighLevel
- Client Secret: provided by GoHighLevel
- OAuth Grant Type:
- Click Save
- Click Manage Connections to return to the list of connections
- Scroll down until you find your new custom connection. Click Connect
- You'll be prompted to give access to the new app you created above. Click on the account with which you'd like to log in (*note: in my tests, I was only able to log into the Sub-Account, as clicking on the Agency entry returned "You do not have access to this feature! Please contact the admin!")
- You'll be logged in, and can return to your sheet to verify that the new connection is now active.
3) Pull GoHighLevel v2 API Data into Sheets
For this request we'll get a list of your contacts, though you can select any endpoint shown in the v2 documentation. This request (and most others) requires your location ID as a parameter. You can get your location ID by navigating to Settings > Business Profile > Location ID, or by simply checking the URL bar while logged into GoHighLevel:
Now set up the request like this:
- Application:
Custom
- Method:
GET
- Request URL:
https://services.leadconnectorhq.com/contacts/?limit=100&locationId=your_location_id
- OAuth:
custom HighLevel
- Headers
- Key =
Version
, Value =2021-07-28
- Key =
Part 3: Handle Pagination
- Note GoHighLevel's limits on the number of records returned on a response. By default, only 20 records will be returned unless you set the
limit
parameter to 100. Then, if you need more than 100 records, use thestartAfter
andstartAfterId
parameters as described in their documentation.
- With API Connector you can loop through each page of results automatically with pagination handling, like this:
- Pagination type:
next page URL
- Next page path:
meta.nextPageUrl
- Run until: choose when to stop fetching data
- Pagination type:
Part 4: API Documentation
Official v1 API documentation: https://public-api.gohighlevel.com/
Official v2 API documentation: https://highlevel.stoplight.io/docs/integrations/0443d7d1a4bd0-overview