LeadCop docs
Stop disposable, fake and mistyped email addresses at the form. Start with one script tag, or call the API from your own code.
Quick start
The fastest way to protect a website. You copy one line of code and paste it into your site.
- Create a free account. No credit card is needed, and your API key is created for you.
- Paste this snippet just before the closing
</body>tag of your website:
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_API_KEY">
</script>That's it. LeadCop finds every email field on your pages, including forms that load later, and checks addresses as people type. A disposable address gets a message and the form won't submit:
Temporary email addresses are not allowed.
Authentication
There are two ways to use LeadCop, and each uses a different kind of key. Pick the one that matches where your check runs.
| Where the check runs | How | Key |
|---|---|---|
| In the visitor's browser | The script tag or plugins. It calls /api/public/check-email for you. | A domain-locked key in data-api-key. Safe to expose. |
| On your server | Call POST /api/check-email for full control over the response. | Your primary key in the Authorization header. Keep it secret. |
Bearer token
Send your primary API key from the dashboard in the Authorization header on every request.
Authorization: Bearer YOUR_API_KEY403. In the browser, use a domain-locked key (one per website, created in the dashboard), or simply the script.Server-to-server header
When calling from your own backend, add the X-LeadCop-Source header so the request is treated as a trusted server-to-server call, which skips the browser-origin check.
Authorization: Bearer YOUR_API_KEY
X-LeadCop-Source: serverCheck an email
One endpoint checks an email and returns the full breakdown. Send the email in the request body.
POST https://leadcop.io/api/check-email
Example request
curl -X POST https://leadcop.io/api/check-email \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-LeadCop-Source: server" \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'Response
A 200 OK with the verdict for the email:
{
"isDisposable": true,
"domain": "mailinator.com",
"reputationScore": 40,
"riskLevel": "Poor",
"tags": ["disposable"],
"reasons": ["Disposable email provider detected"],
"isValidSyntax": true,
"isRoleAccount": false,
"isFreeEmail": false,
"isInvalidTld": false,
"didYouMean": null,
"mxValid": true,
"smtpValid": true,
"requestsRemaining": 999
}Response fields
| Field | Type | Meaning |
|---|---|---|
isDisposable | boolean | True if the domain is a disposable or temporary provider (or blocked by your policy). |
reputationScore | number | 0–100 quality score. Higher is safer; it combines every signal below. |
riskLevel | string | Readable band: Excellent, Good, Medium, Poor or Critical. |
didYouMean | string | null | Suggested correction for a likely domain typo, e.g. "gmail.com" for "gmial.com". |
isRoleAccount | boolean | null | True for role addresses like info@ or admin@. Null if your plan lacks role detection. |
isFreeEmail | boolean | null | True for free providers (Gmail, Yahoo…). Null if your plan lacks free-provider detection. |
isInvalidTld | boolean | True if the top-level domain is not a valid, recognized TLD. |
mxValid | boolean | True if the domain has valid MX (mail exchange) records. |
tags | string[] | Machine-readable labels, e.g. ["disposable", "role_account"]. |
reasons | string[] | Readable explanations for the score and any block. |
requestsRemaining | number | Requests left in your current billing period, or of your one-time allowance on the free plan. |
isAllowlisted | boolean | True if the address or its domain is on your allowlist (for all keys or for the key in the request). Allowlisted emails return clean flags and should always be accepted. Paid plans. |
Error codes
Errors come back with an HTTP status and a JSON body like { "error": "…" }.
| Status | What it means | What to do |
|---|---|---|
400 Bad Request | Invalid request payload | The request body was missing the email field, was empty, or was not valid JSON. Returns { "error": "Invalid request payload" }. |
401 Unauthorized | Invalid API key | The Authorization header is missing, malformed, or the API key does not match any account. |
403 Forbidden | Key used in the wrong context | Either a primary key was called from a browser (primary keys are server-to-server only), or a domain-locked key was used on a domain it isn't authorized for. |
429 Too Many Requests | Rate limit exceeded | Either your request quota is used up (upgrade your plan; paid plans refill each billing period, the free allowance is one-time), or you exceeded your per-minute burst limit (plan requests per second × 60). Slow down and retry. |
500 Internal Server Error | Transient server error | A temporary error on our side. Requests are safe to retry. The embedded script and plugins fail open, so form submissions are never blocked by an outage. |
Shopify
Protect your storefront's newsletter signups, contact forms and customer registration.
Add the script to theme.liquid
- In your Shopify admin, open Online Store → Themes.
- Click … next to your active theme and choose Edit code.
- Open
layout/theme.liquid. - Paste the script immediately before the closing
</body>tag:
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_API_KEY">
</script>YOUR_API_KEY with a domain-locked key for your store from the LeadCop dashboard.WordPress
The native plugin protects default registration, comments, WooCommerce and popular form builders, checked on your server.
Install the plugin
- In your WordPress admin, go to Plugins → Add New.
- Search for LeadCop.
- Click Install Now, then Activate.
- Open the new LeadCop menu in your admin sidebar.
- Paste your API key and click Save Settings.
The plugin is on the official directory, so it installs in one click. View it on WordPress.org. For a manual install, download the .zip there, then use Plugins → Add New → Upload Plugin.
Forms it protects out of the box
- WordPress registration
- Comment forms
- WooCommerce checkout
- Contact Form 7
- WPForms
- Gravity Forms
Or use the script
Prefer no plugin? Paste the script before </body> in your theme's footer.php, or with a header and footer code plugin such as WPCode.
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_API_KEY">
</script>Wix
The method depends on whether your site is on a Wix Premium or a free plan.
Wix Premium: Custom Code
- In your Wix dashboard, open Settings.
- Under Advanced, click Custom Code.
- Click + Add Custom Code.
- Paste the LeadCop script.
- Set Place Code in to Body - end.
- Choose All Pages (or your contact page) and click Apply.
Wix free plan: HTML embed
The free plan has no Custom Code, so embed your form and the script together inside one HTML element:
<form action="YOUR_FORM_SUBMIT_URL" method="POST">
<input type="email" name="email" required />
<button type="submit">Join the list</button>
</form>
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_API_KEY">
</script>Webflow
LeadCop checks native Webflow form submissions automatically once the script is on your site.
- Open your Webflow Project Settings.
- Go to the Custom Code tab.
- Paste the script into Footer Code.
- Click Save Changes and publish your site.
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_API_KEY">
</script>Framer
Add the script to protect signup forms and lead capture on your Framer site.
- Open your project and click Project Settings (the gear icon).
- Choose General in the left sidebar.
- Scroll to Custom Code.
- Paste the script into End of <body>, then save and publish.
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_API_KEY">
</script>Next.js and React
Use the leadcop-react package, or call the API yourself from client components or server code.
The leadcop-react package
Hooks, a script component and a server helper, with every dashboard rule applied (your allowlist and country rules included in the browser). leadcop-react on npm
npm install leadcop-react"use client";
import { LeadCopProvider, useEmailCheck } from "leadcop-react";
// Wrap your form: <LeadCopProvider apiKey={process.env.NEXT_PUBLIC_LEADCOP_KEY!}>
const { status, message, check } = useEmailCheck(email);
// On submit: const verdict = await check(); if (!verdict.allow) return;// Server Action or API route (every rule except country)
import { verifyEmail } from "leadcop-react/server";
const r = await verifyEmail(email); // uses process.env.LEADCOP_API_KEY (your primary key)
if (!r.allow) return { error: r.reasons[0] };Without the package: a React hook
Check as the user types, with a 500ms pause to limit requests:
import { useState, useEffect } from "react";
type Check = { allow: boolean; message: string | null; checking: boolean };
export function useEmailCheck(email: string): Check {
const [result, setResult] = useState<Check>({ allow: true, message: null, checking: false });
useEffect(() => {
if (!email || !email.includes("@")) return;
const delay = setTimeout(async () => {
setResult(prev => ({ ...prev, checking: true }));
try {
// Use a domain-locked key here. Primary keys are server-to-server only
// and return 403 from a browser. Create one under API Keys in the dashboard.
const res = await fetch("https://leadcop.io/api/public/check-email", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, apiKey: "YOUR_DOMAIN_LOCKED_KEY" }),
});
const data = await res.json();
// `allow` already applies every dashboard rule for this key,
// including your allowlist and country rules.
setResult({ allow: data.allow !== false, message: data.message ?? null, checking: false });
} catch {
// Fail open: never block a real user because the check failed.
setResult({ allow: true, message: null, checking: false });
}
}, 500);
return () => clearTimeout(delay);
}, [email]);
return result;
}Your dashboard rules in custom code
- Rules follow the key. Both endpoints apply the dashboard settings for the API key you send (enabled checks, block or warn, your messages). The public endpoint returns a final
allowandshouldBlockwith yourmessage. - Every signal is there. The
checksobject (checks.role,checks.disposable,checks.freeProviderand more) lets you ignoreallowand write your own logic. - Allowlist. Allowlisted emails always return
allow: true, and the public endpoint addsallowlisted: true. On/api/check-emailthey return clean flags plusisAllowlisted: true. - Country rules need a browser-side check. LeadCop only knows the visitor's country when their browser calls us. Server-side calls come from your server's location, so country rules never apply to them. See Country rules.
Country rules
Block sign-ups from the countries you choose, or accept only the countries you serve. Available on all paid plans; turn it on per API key under API Keys → Widget settings → Countries.
When country rules apply
Country rules use the visitor's location, so the check has to happen in their browser. That works in any stack.
| How your site checks emails | Country rules |
|---|---|
| The LeadCop script on the page (any stack) | Applied |
A browser-side fetch to /api/public/check-email | Applied |
Your server calls /api/check-email (PHP, a Next.js API route or Server Action, Node, Python) | Not applied: we see your server's location |
| The WordPress plugin | Not applied: add the script as well |
Add the script
The script finds email fields on its own, including forms your framework renders later, and stops the form before your own submit handler runs.
Next.js (App Router), in app/layout.tsx
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_DOMAIN_LOCKED_KEY"
strategy="afterInteractive"
/>
</body>
</html>
);
}React (Vite or Create React App), in index.html before </body>
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="YOUR_DOMAIN_LOCKED_KEY">
</script>PHP or Laravel Blade, in your shared layout or footer
<!-- resources/views/layouts/app.blade.php, footer.php, etc. -->
<script
src="https://leadcop.io/leadcop-email-validator.js"
data-api-key="<?= htmlspecialchars(getenv('LEADCOP_PUBLIC_KEY')) ?>">
</script>Or check from your own UI
Call the public endpoint from the browser and use its verdict. When a country rule matches, reason is "country" and message is the text you set in the dashboard.
// Runs in the browser (a client component), so LeadCop sees the visitor's country.
const res = await fetch("https://leadcop.io/api/public/check-email", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ apiKey: "YOUR_DOMAIN_LOCKED_KEY", email }),
});
const r = await res.json();
if (r.allow === false) {
showError(r.message); // e.g. "Sign-ups from your region are not accepted."
}
// r.reason → "country", "disposable", "role_account", ...
// r.country → visitor country, e.g. "US" (null if unknown)Good to know
- Use a domain-locked key in browser code. The key is visible in the page; the domain lock stops other sites from using it.
- Unknown countries are let through. If the country can't be determined, a country rule never blocks the visitor.
- VPN users appear in the VPN's country.
- Browser checks can be skipped by bots that post straight to your server. If you also check on your backend, every rule applies there except country rules, which are on our roadmap for server-side calls.
- Your allowlist wins. An allowlisted email or domain passes even from a blocked country.
Frequently asked questions
- How does the real-time email check work?
- LeadCop runs several checks in under 100ms: the syntax, the TLD, role-based accounts (like sales@ or admin@), and the domain against our database of more than 200,000 known temporary and disposable email providers.
- What happens if the LeadCop API is down?
- Every LeadCop script and plugin fails open. If our API is unreachable, the check is skipped and the form submission goes through, so your signups are never blocked by an outage.
- How do I always let a trusted domain or address through?
- Use the Allowlist (Dashboard → Allowlist, paid plans). Add a domain like partner.com or a single address like [email protected] and choose which API key it applies to, or all keys. Allowlisted emails pass every rule, including your blocklist, on both the website script and the WordPress plugin.
- Can I block sign-ups from certain countries?
- Yes, on paid plans: Dashboard → API Keys → Widget settings → Countries. Block the countries you choose, or allow only the countries you serve. Country rules work with the LeadCop website script only. They are not applied to the WordPress plugin or to direct API calls, because those requests come from the website's server rather than the visitor. Visitors using a VPN appear in the VPN's country, and visitors whose country can't be determined are let through.
- What does the free email warning do?
- When it's on, the script shows a warning (but does not block) if someone enters a Gmail, Yahoo, Hotmail or other free-provider address. Useful for B2B products that want a work email without turning anyone away.
Ready to stop fake signups?
Setup takes about two minutes, and the free plan needs no card. Stuck on an install? Email us and we'll help.