# Connect

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

## How it installs

Zernio is a LeadConnector 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 LeadConnector 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. LeadConnector returns you to Zernio.
4. Sign in to Zernio, or create an account, and pick the profile the install joins. With a single profile, Zernio picks it for you.

Zernio saves one connected account per sub-account. For an agency install, the sub-accounts connect in the background within a few minutes.

The link Zernio shows after the install is valid for one hour and works once. If it expires, install the app again.

## 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.leadconnectorhq.com/oauth/chooselocation?client_id=…", "state": "…" }
```

The user approves access. LeadConnector 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

Disconnect from either side:

- `DELETE /v1/accounts/{accountId}` (or **Disconnect** in the dashboard) disconnects the sub-account in Zernio, stops the relay and uninstalls the Zernio app from that sub-account in LeadConnector. Only that sub-account: the agency's other sub-accounts keep the app. If the same sub-account is also connected on another Zernio profile, the app stays installed for that profile.
- Uninstalling the Zernio app in LeadConnector revokes the app's access, and Zernio disconnects the sub-account.

What Zernio already wrote stays in LeadConnector: 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 and workflow trigger subscriptions.
- 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 | LeadConnector refused the code exchange, or the location could not be read | Start the connect again; check the install covers this sub-account. |
| "This link has expired" after a marketplace install | The install was not claimed within an hour, or was already claimed | Install the app again from the marketplace. |
| `503` on `GET /v1/connect/gohighlevel` | LeadConnector is not configured on this Zernio environment | Contact support. |

## Related

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