# Connect

Install the Zernio app from the GoHighLevel marketplace, with agency bulk install, and connect a sub-account through OAuth.

## How it installs

Zernio is a GoHighLevel marketplace app, distributed to sub-accounts with bulk install on. There are two ways in:

- **Agency bulk install:** an agency owner installs the app across many sub-accounts in one operation. Zernio enumerates the installed sub-accounts, mints a location token for each, and subscribes to `AppInstall` so every sub-account added later (including under a SaaS plan) is covered automatically.
- **Single sub-account:** a sub-account installs the app for itself.

Each installed sub-account (location) becomes one connected Zernio account with `platform: "gohighlevel"`.

## Install from the marketplace

1. Open the Zernio listing in the GoHighLevel marketplace and choose **Install**.
2. As an agency, pick the sub-accounts to install across, or choose all; as a sub-account, install for your location.
3. Approve the requested scopes. GoHighLevel returns you to Zernio, which saves a connected account per sub-account.

## Connect with the API

Request the authorization link for a profile, then send the user to `authUrl`:

```bash
curl "https://zernio.com/api/v1/connect/gohighlevel?profileId=PROFILE_ID&redirect_url=https://example.com/done" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

```json
{ "authUrl": "https://marketplace.gohighlevel.com/oauth/chooselocation?client_id=…", "state": "…" }
```

The user approves access. GoHighLevel returns them to Zernio, which exchanges the code for a location token and a rotating refresh token, then saves the account.

Zernio then redirects to `redirect_url` (or the dashboard) with `connected=gohighlevel`, `profileId`, `accountId` and the location.

Zernio uses the OAuth 2.0 Authorization Code grant without PKCE. The access token is short-lived and the refresh token rotates, so Zernio stores the new one on every refresh.

## Disconnect

Uninstall the Zernio app in GoHighLevel, or call `DELETE /v1/accounts/{accountId}`. Zernio stops the relay for that sub-account and revokes its token.

What Zernio already wrote stays in GoHighLevel: the custom fields, contacts and opportunities it updated are not removed. Nothing new is sent until the app is installed again.

## How it behaves

- One connected account per sub-account (location). Reinstalling refreshes the account in place and keeps its settings.
- Access renews by itself. If the app is uninstalled or its access is revoked, the account is marked disconnected the next time an event is processed.

## If it fails

| Error | Cause | Fix |
|-------|-------|-----|
| `gohighlevel_access_denied` on the redirect | The user declined access | Start the connect again and approve access. |
| `gohighlevel_invalid_state` on the redirect | The link expired or was already used | Request a fresh `authUrl`. |
| `gohighlevel_connection_failed` on the redirect | GoHighLevel refused the code exchange, or the location could not be read | Start the connect again; check the install covers this sub-account. |
| `503` on `GET /v1/connect/gohighlevel` | GoHighLevel is not configured on this Zernio environment | Contact support. |

## Related

- [Settings](/platforms/gohighlevel/settings)
- [What syncs](/platforms/gohighlevel/sync)
- [Limits and errors](/platforms/gohighlevel/reference)