# Connect

Install the Zernio app on a Wix site to connect it, from the dashboard or with the connect API.

## Connect a Wix site

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

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

```json
{ "authUrl": "https://www.wix.com/app-installer?appId=…", "state": "…" }
```

The user picks one of their Wix sites and approves the app. Wix returns them to Zernio, which saves the account and redirects to `redirect_url` (or the dashboard).

Connecting the same site to the same profile again refreshes the account in place.

## How it behaves

- Access renews by itself: Zernio mints a new Wix token whenever the current one is about to expire.
- Removing the Zernio app from the site in Wix disconnects the account.
- Wix posts need a site member as author. Zernio uses the author of the site's latest post, or creates an author member named after the site when there are no posts yet.

## If it fails

| Error | Cause | Fix |
|-------|-------|-----|
| `wix_install_failed` on the redirect | The installer did not return a valid signed install, or Wix refused the app | Start the connect again from a fresh `authUrl`. |
| `wix_connection_failed` on the redirect | The site could not be read after install, for example Wix Blog is missing | Add Wix Blog to the site and connect again. |
| `503` on `GET /v1/connect/wix` | Wix is not configured on this Zernio environment | Contact support. |