# Add Bugerz to a website

Bugerz collects bug reports with screenshots and page context. An AI website builder prepares the installation and pastes its public widget key into the website. Give the person the returned setup link so they can choose their own password or log in and confirm the connection. Email is a fallback, not a prerequisite for a new signup.

Ask the person for their owner email, project name and website URL, and confirm they want Bugerz installed. Do not infer an email from unrelated files or ask for passwords or inbox access.

## Prepare an installation

Generate and retain a random UUID or 32–128 random base64url characters as the idempotency key. Use the same key and body on every retry, including after network timeouts. This prevents duplicate installations and duplicate activation emails.

```sh
curl https://bugerz.com/api/v1/installations \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: REPLACE_WITH_A_RETAINED_RANDOM_UUID' \
  --data '{"email":"owner@example.com","projectName":"Customer website","websiteUrl":"https://example.com/"}'
```

The JSON response has `ok: true` and an `installation` object with:

| Field | Meaning |
| --- | --- |
| `id` | Installation identifier. |
| `status` | `pending_claim`, `active`, `expired`, or `revoked`. |
| `publicKey` | Public browser widget key. Safe to embed in the website. |
| `snippet` | Ready-to-paste script and initializer for this Bugerz server. |
| `setupUrl` | Direct setup link, returned on preparation/retry. Give it to the person to open themselves. Do not redeem it, put it in the website, or choose a password for them. |
| `delivery` | `link` by default; `email` sends an immediate activation email when explicitly requested. |
| `fallbackEmailAt` | Unix milliseconds for the conditional email fallback deadline; `null` for immediate email delivery. |
| `statusToken` | Read-only installation status credential, returned on preparation/retry. Keep out of website source and URLs. |
| `statusUrl` | Endpoint to check using the status token in the Authorization header. |
| `expiresAt` | Activation deadline as Unix milliseconds (seven days after preparation). Active keys continue working after this deadline. |
| `collectionEnabled` | Whether this installation's key is currently active. |
| `emailStatus` | Link delivery uses `conditional` while pending and `not_required` afterward. It does not reveal account existence or reminder delivery. Immediate email uses `queued`, `sent`, or `failed`; `sent` means SMTP accepted it, not confirmed inbox delivery. |

The API never returns an email verification link, an account session, or a private management key. The direct setup link is a separate capability: it can create a new account, but it cannot verify an email or bypass an existing account's password. The response is the same shape whether or not the email has an account. No user, project, or usable report key is created until the person confirms setup.

The default is `"delivery":"link"` (it can be omitted). Return `setupUrl` to the person immediately. If they still have no account and have not completed setup after 30 minutes, Bugerz queues an email fallback. The operator can configure this delay with `INSTALLATION_REMINDER_MINUTES` (1–1440, default 30). Creating an account or completing setup cancels the fallback. An email already in flight may still arrive. Existing accounts receive no automatic fallback; their owner can log in directly. To request immediate email instead, add `"delivery":"email"` to the preparation body. The first delivery choice is retained across retries; changing it with the same key returns `409`.

The person must open and redeem the setup link themselves. An AI tool must not create or submit a password or finish signup on their behalf. Keep setup links private to that conversation. They expire after seven days and become unusable once setup is confirmed. The status token cannot be exchanged for a setup link; preparation retries require the original idempotency key.

Website URLs must be HTTP or HTTPS and contain no credentials, query or fragment. The URL describes the installation; it does not verify ownership of that domain or limit where a public widget key can be used. Bugerz never fetches the supplied website URL.

## Install the widget

Paste the returned `snippet` once, just before the closing `</body>` tag. For reference, it has this form:

```html
<script src="https://bugerz.com/javascripts/bugerz.min.js"></script>
<script>BugerZ.init({ publicKey: 'PUBLIC_KEY_FROM_RESPONSE' });</script>
```

For React or Next.js, load the script and initialize it once on the client after the script is ready. Guard against duplicate initialization during navigation. No secret belongs in client code. See [/documentation](/documentation) for widget options, custom buttons, screenshot privacy and programmatic reports.

The pending key rejects report submissions until confirmation. Ask the person to open `setupUrl` before testing reports. A new user chooses a password, gets a Free account and is signed in. This direct signup leaves their email unverified; email verification remains available separately. Existing customers log in and select a project they own. Creating a new paid project requires their billing acknowledgement. New-project notification emails are chosen during setup; an existing project uses its current settings.

If the person signs up or logs in through the regular account pages, Bugerz recovers setup links previously opened in that browser and offers them under `/installations/pending`. Accounts with a verified email can also find all unfinished installations for that address, including after changing browsers. Unverified accounts need the original setup link or the browser in which it was opened; merely typing an email cannot reveal someone else's pending setups. The dashboard also offers a pending-setup link. Failed signup email delivery does not prevent continuing a setup already opened in that browser.

## Check activation

```sh
curl https://bugerz.com/api/v1/installations/INSTALLATION_ID \
  -H 'Authorization: Bearer STATUS_TOKEN_FROM_RESPONSE'
```

Poll no more than once per minute. This endpoint exposes only installation state, the public key and snippet. It cannot read reports or manage the account. Once `active`, send one disposable test report through the widget and have the owner confirm it appears in their project. Standard report/storage limits apply. Do not create test reports without the person's request.

`expired` means activation did not happen within seven days. Start a new installation with a new idempotency key if the person requests another activation email. `revoked` means the activated key or project was removed or disabled; the owner must manage that from Bugerz. Do not recreate revoked installations automatically.

## Errors and limits

- `400`: Correct the email, project name, website URL or idempotency key.
- `404`: The installation ID/status token is invalid, or its retained status record has been cleaned up.
- `409`: An idempotency key was reused with a different request. Retry the original request; use a new key only for an intentionally different installation.
- `410`: The server's session secret changed and invalidated the previous installation credentials. Ask the owner before requesting a new installation.
- `413`: The request body exceeds 8 KB.
- `429`: Wait before retrying. Public checks are limited to 60 per IP per 15 minutes. Preparation also has durable limits of three installations per email per day, ten per IP network per hour, and 1,000 pending installations across the service.
- `503`: Server installation configuration is incomplete; the site operator must fix it.

Email delivery retries up to six times with backoff. For immediate email, `emailStatus: failed` means the operator should check SMTP. The direct setup link remains available without SMTP. Repeating preparation with the same key never resends mail or resets the fallback timer. Delivery can be duplicated if SMTP accepts a message but its acknowledgement is lost. Records are retained until 30 days after the activation deadline; cleanup does not delete claimed accounts, projects or report keys. Setup/status credentials are derived from the session secret; rotating it invalidates preparation retries and queued encrypted mail. Previously issued setup/status tokens remain valid until expiry/consumption when their validation hashes are retained.

## Machine interfaces

- [OpenAPI schema](/openapi.json)
- [Widget documentation](/documentation)

The MCP adapter exposes `prepare_installation` and `get_installation_status` over this API. Setup instructions are in `integrations/mcp/README.md` in the server checkout. Private report access requires a future owner-authorized integration.
