# Widget

Check addresses in your signup form as visitors type: typos, dead domains and throwaway inboxes are caught before they become accounts.

## Install

1. In **Dashboard → Integrations**, create a publishable key (`mf_pub_...`) and list the exact origins of your site (for example `https://example.com`).
2. Add the script and mark the field:

```html
<script src="https://mails.fit/widget.js" defer></script>
<input type="email" name="email" data-mailsfit="mf_pub_..." data-mailsfit-block="invalid">
```

The widget checks on blur, or 800 ms after typing stops, shows a message (and a typo suggestion) under the field, and blocks the form with `setCustomValidity` for the statuses in `data-mailsfit-block` (`invalid` by default, `invalid,risky`, or `none`). Network errors and refusals never block the form.

## Events

```javascript
document.querySelector("input[data-mailsfit]").addEventListener("mailsfit:result", (e) => {
  console.log(e.detail); // { email, status: "ok" | "risky" | "invalid" | "unavailable", suggestion }
});
```

## Cost and limits

- One credit per check from the key owner's balance; `unknown` results are refunded.
- A daily cap per key (default 500, 1 to 50,000, set in the dashboard); past it the answer is `unavailable`.
- 30 checks a minute per key, 10 per key and visitor IP.
- The publishable key and allowed origin are public, so the caps bound what a copied key can spend. It grants nothing else.

## Endpoint

The script calls `POST /v1/widget/check?key=mf_pub_...` with `{"email": "..."}` and gets `{"status": "ok" | "risky" | "invalid" | "unavailable", "suggestion": null}`. Server-side code should use [`/v1/verify`](/docs/verify) with a secret key instead.
