Documentation
CyberFence screens every sign-up with one API call from your backend. Clear abuse is refused; suspicious sign-ups are held back by the trust rules and Agent, and can appeal. API base URL: https://api.cyberfence.dev.
Quickstart
- Create a workspace, then an API key under API keys (test keys work immediately; live keys need a verified email).
- Store it on your server as
CYBERFENCE_KEY. Never ship it to the browser. - Call
protect()before creating the user. Onreview, create the account but give no trial until it is approved.
npm i @cyberfence/nodeimport { CyberFence, requestContext } from '@cyberfence/node';
const fence = new CyberFence({ apiKey: process.env.CYBERFENCE_KEY! });
app.post('/signup', async (req, res) => {
const verdict = await fence.protect({
email: req.body.email,
name: req.body.name,
timeZone: req.body.timeZone, // from the browser, optional
timeToSubmitMs: req.body.timeToSubmitMs, // optional
...requestContext(req.headers, req.socket.remoteAddress), // ip, userAgent, country, language
});
if (verdict.decision === 'deny') return res.status(403).json({ error: verdict.message });
const user = await db.users.create({
email: verdict.normalizedEmail,
status: verdict.decision === 'review' ? 'held_back' : 'active',
evaluationId: verdict.id,
});
if (verdict.id) await fence.report(verdict.id, { outcome: 'created', externalUserId: user.id });
// Put verdict.emailOpenPixelUrl in your verification email (rule 10).
await sendVerificationEmail(user, { pixelUrl: verdict.emailOpenPixelUrl });
res.json({ ok: true, heldBack: verdict.decision === 'review', message: verdict.message });
});Integrate with an AI coding agent
AI coding agents — Claude Code, Cursor, Copilot and others — can do the whole integration for you: install the SDK, wire protect() into your sign-up handler, hold back on review, add the rule 10 pixel and verify-click call, the appeal form and the webhook receiver. Paste this prompt into your agent:
Integrate CyberFence sign-up protection into this app. Follow the instructions at https://cyberfence.dev/llms-full.txt exactly (also shipped as node_modules/@cyberfence/node/AGENTS.md after install).- /llms-full.txt is the full agent playbook and SDK reference; /llms.txt is the short index (llmstxt.org format).
- The same playbook ships inside the npm package as
node_modules/@cyberfence/node/AGENTS.md, so agents find it offline after install. - Using Claude Code? The repo includes a skill,
cyberfence-integrate(skills/cyberfence-integrate/SKILL.md), that runs the integration step by step.
Node SDK
@cyberfence/node has zero dependencies and works on Node 18+, Bun, Deno and edge runtimes with fetch.
| Method | Purpose |
|---|---|
new CyberFence({ apiKey, baseUrl?, timeoutMs?, failOpen? }) | Client. baseUrl defaults to CYBERFENCE_URL or the hosted API. |
protect(input) | Evaluate a sign-up. With failOpen (default true) network errors, 5xx and 429 return allow with failedOpen: true; bad keys and bad input still throw CyberFenceError. |
report(id, { outcome, externalUserId?, note? }) | created links your user id; customer marks a paying customer (the domain becomes known-good, exempt from rules 1 and 11); fraud rejects it. |
verifyClick(id, { pageReferrer, origin, referer, appHost }) | Rule 10 from your verify-email handler. verifyClickContext(headers, pageReferrer) builds the input. Fails open. |
appeal(id, { website, useCase }) | A held-back user asks for a review. Returns { status: "approved" | "pending_review", evaluation }. |
review(id, { action, note? }) | Approve / reject a held-back sign-up from your own tooling. |
getEvaluation(id) | Fetch an evaluation. |
verifyWebhook(rawBody, header, secret) | Verify and parse a webhook. Throws WebhookVerificationError. |
requestContext(headers, remote?) | ip (CF-Connecting-IP → X-Real-IP → X-Forwarded-For → socket), userAgent, country and language. |
API reference
Authenticate with Authorization: Bearer cf_live_… (or cf_test_…). Errors are JSON: { "error": { "message", "status" } }.
POST /v1/protect
Always answers 200 with a decision, except 429 quota_exceeded when a Free workspace is over its monthly quota (the SDK fails open).
| Field | Type | Description |
|---|---|---|
email | string, required | Email exactly as typed. Normalization (plus-alias, Gmail dots) happens server-side. |
name | string | Full name. Used by rules 3, 6, 8, 12 and by Agent. |
ip | string | End-user IP. Use getClientIp() / requestContext() from the SDK. Never sent to the agent. |
userAgent | string | End-user User-Agent header. |
provider | string | "credentials" (default), "google", "github", … |
isPasswordSignup | boolean | Override; defaults to provider === "credentials". Rules 3, 6, 9 and the captcha requirement only apply to password sign-ups. |
country | string | ISO-2 country of the network, e.g. from cf-ipcountry. Used by rule 7 and by Agent. |
timeZone | string | Browser time zone (Intl.DateTimeFormat().resolvedOptions().timeZone). Agent compares it with the country. |
language | string | Browser language (navigator.language or Accept-Language). Agent compares it with the country. |
captchaToken | string | Turnstile / hCaptcha / reCAPTCHA token; verified server-side if configured. |
timeToSubmitMs | number | Milliseconds between form render and submit. Under 1.5s sets bot.tooFast. |
honeypot | string | boolean | Value of a hidden field. Anything non-empty is a bot. |
externalUserId | string | Your user id. Echoed back in webhooks. |
metadata | object (≤4KB) | Arbitrary JSON echoed back in webhooks. |
debug | boolean | Include the full signal vector and decision trace in the response. |
Response:
| Field | Description |
|---|---|
id | Evaluation id (evl_…). Store it with the user — you need it for verify-click, appeals and reports. |
decision | allow | review | deny — what your app should do. review = held back. Always allow in dry-run mode. |
modelDecision | What the model decided (differs from decision only in dry-run). |
reason | Reason code, e.g. disposable_email, rule3_one_word_name, rule13_agent_sure, ok. |
score | Weak-signal risk score (0+). |
message | End-user-safe message. Empty for allow. |
normalizedEmail | Canonical email — use it as the unique key for the account. |
status | allowed | pending_review | denied (later approved / rejected). |
ai | Agent’s opinion when it answered: { verdict: "real" | "suspicious", confidence, signal }. |
emailOpenPixelUrl | Signed 1×1 GIF URL for your verification email (rule 10). |
dryRun / livemode | Workspace mode and key mode. |
latencyMs | Server-side processing time. |
curl -X POST https://api.cyberfence.dev/v1/protect \
-H "Authorization: Bearer $CYBERFENCE_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","name":"Jane Doe","ip":"203.0.113.7","country":"US",
"timeZone":"America/New_York","language":"en-US","userAgent":"Mozilla/5.0 ..."}'GET /v1/evaluations/:id
Returns id, email, decision, modelDecision, reason, score, status, livemode, externalUserId, metadata, reviewedAt, reviewNote, aiReview, appeal, postSignup, isCustomer, createdAt.
POST /v1/evaluations/:id/report
Body { "outcome": "created" | "customer" | "fraud", "externalUserId"?, "note"? }.
POST /v1/evaluations/:id/verify-click
Body { "pageReferrer"?, "origin"?, "referer"?, "appHost"? } → { tempMailHost, heldBack, evaluation }. See rule 10.
POST /v1/evaluations/:id/appeal
Body { "website", "useCase" } → { status: "approved" | "pending_review", evaluation }. 400 if the answers are too short, 409 if the sign-up is not held back, was already appealed, or appeals are off.
POST /v1/evaluations/:id/review
Body { "action": "approve" | "reject", "note"? }. 409 if not pending_review. Fires signup.approved / signup.rejected.
Test & live keys
cf_test_…keys run the full pipeline (decision model, Agent, webhooks withlivemode: false) with velocity counters isolated from live traffic, and never count toward your quota.cf_live_…keys require a verified email to create.- Keys are shown once. Only an HMAC is stored; revoke and recreate if one leaks.
- Dry-run is a workspace mode: live keys always get
allow, the real decision is recorded asmodelDecision.
Trust rules
The default policy is the sign-up trust rule set from Scalelist’s production system, measured on 26k real sign-ups (rules 1–6, 11 and 12 held back zero paying customers). There are two outcomes for a bad sign-up:
- deny — clear abuse (disposable, no MX, bots, Tor, honeypot, failed captcha, network floods). Refuse the sign-up.
- review — held back, not lost. The trust rules below only hold back: create the account but give no free trial or credits until a person — or Agent on appeal — approves it.
| Rule | Reason | Holds back when |
|---|---|---|
| 1 | rule1_throwaway_domain | 5+ accounts on one unpaid company domain in 30 days (or mail.com). |
| 2 | rule2_subdomain_email | Email on a sub-domain of a company domain, and the name is not in the email. |
| 3 | rule3_one_word_name | Password sign-up with a one-word name that is not in the company email (general inboxes, initials and the company name itself are fine). |
| 4 | rule4_digits_in_company_email | Company email with 3+ digits in a row. |
| 5 | rule5_student_email | Student email, or a university email that does not fit the name. |
| 6 | rule6_repeated_name | Same full name on 5+ password sign-ups in 30 days. |
| 7 | rule7_country | Country in the workspace hold-back list (Settings → Trust rules). Off by default. |
| 8 | rule8_junk_name | Junk one-word name on a webmail address. |
| 9 | rule9_temp_gmail | Password sign-up with a Gmail address in the temp-Gmail dot pattern. |
| 10 | rule10_temp_mail_* | After sign-up: the verification email was opened, or its link clicked, on a temp-mail site. |
| 11 | rule11_same_network | 3+ accounts from one network in 24 hours (known-good company domains exempt). |
| 12 | rule12_mashed_name | Name typed by mashing keys, on a webmail address. |
| 13 | rule13_agent_sure | Agent says suspicious at ≥ sureConfidence (default 0.85). |
Evaluation order (first match wins):
| Reason | Outcome |
|---|---|
allowlisted_domain | allow — trusted domain bypasses everything |
blocklisted_domain | deny — blocked by an admin |
honeypot / invalid_email / disposable_email / no_mx_records | deny |
bot / tor / captcha_failed / captcha_required | deny |
ip_blocked (10+/hour) / rate_limited (3+/10 min) | deny |
domain_blocked (company domain, 5+ denials in 30 days) | deny |
rules 1–13 (above) | review — held back |
elevated_risk (score ≥ 50) | review — held back |
ok | allow |
Mark a paying customer with report(id, { outcome: "customer" }) or the dashboard toggle: its domain becomes domain.knownGood and is exempt from rules 1 and 11.
Agent
Agent is TypeSafe’s structured-decision model typesafe/jev-1.13, called through OpenRouter’s Decisions API (not chat completions). For every sign-up it receives a small JSON state and answers two typed questions — about $0.00002 per check:
verdict: real or suspicious, with a confidence.signal: the main warning sign, one of the values below.
| signal | Meaning |
|---|---|
none | No warning sign. |
random_name | The name looks random, typed by mashing keys, or is not a person name. |
generated_email | The email looks machine-made (random letters, long number runs). |
name_email_mismatch | The name and the email clearly belong to different people. |
country_mismatch | The network country, time zone and language clearly disagree. |
many_accounts_same_network | Several accounts came from the same network recently. |
many_accounts_same_domain | Several accounts came from the same company domain recently. |
repeated_name | The same name was used for other recent sign-ups. |
throwaway_domain | The email domain looks like a throwaway or made-up domain. |
Facts sent to the agent (no raw IP, ever):
name, email, emailDomain, emailIsWebmailipCountry (the country, never the IP), browserTimeZone, browserLanguageaccountsFromSameNetworkLast24h, accountsFromSameCompanyDomainLast24h, accountsWithSameNameLast7Dayscontext: your “Business context for Agent” setting
- Rule 13: Agent only decides on its own when it is sure —
suspiciousat ≥sureConfidence(default 0.85) holds the sign-up back. Below that, its opinion is stored for reviewers. - Privacy: requests are routed only to zero-data-retention providers that don’t collect data (Settings → Agent, on by default).
- Fails open: no OpenRouter key, a timeout or an error means Agent is skipped and the rules decide alone. A real person is never punished for an outage.
- Bring your own OpenRouter key and business context in Settings → Agent. The response’s
aifield carries{ verdict, confidence, signal }.
After sign-up (rule 10)
Throwaway inboxes often pass every check at sign-up. Rule 10 catches them when the verification email is used, and holds an allowed sign-up back after the fact (webhook signup.held_back). Turn it on or off with Settings → Trust rules.
1. Email-open pixel
Put the signed emailOpenPixelUrl from the protect response in your verification email as a 1×1 image. Opened on a temp-mail site → held back.
<img src="{{ emailOpenPixelUrl }}" width="1" height="1" alt="" style="display:block;border:0" />2. Verify-link click
Have your verify page send document.referrer to your backend, then forward it with the request’s Origin / Referer:
import { verifyClickContext } from '@cyberfence/node';
app.post('/verify-email', async (req, res) => {
const user = await db.users.verify(req.body.token);
const r = await fence.verifyClick(user.evaluationId, verifyClickContext(req.headers, req.body.pageReferrer));
// POST /v1/evaluations/:id/verify-click { pageReferrer, origin, referer, appHost }
if (r.heldBack) await db.users.holdBack(user.id); // clicked from a temp-mail site
res.json({ ok: true });
});Appeals
Held back, not lost. When appeals are on (default), show held-back users a short form: their company website or LinkedIn, and what they want to do.
const r = await fence.appeal(user.evaluationId, {
website: 'https://acme.com', // or a LinkedIn URL
useCase: 'Find leads for our agency', // at least a few words
});
// POST /v1/evaluations/:id/appeal { website, useCase }
if (r.status === 'approved') await db.users.activate(user.id);
// 'pending_review' → a reviewer decides; you get signup.approved / signup.rejected- Agent runs a second check. With auto-approve on, an
approveat ≥minConfidence(default 0.8) approves the sign-up and firessignup.approved. - Anything else stays held back for a reviewer, with the appeal attached, and fires
signup.appealed. - An appeal can be sent once. Errors: 400 (answers too short), 409 (not held back, already appealed, or appeals off).
Decision model
Every workspace runs a GoRules JDM graph on the ZEN engine. Download it from the dashboard, edit it at editor.gorules.io, test it in the simulator, then publish (Pro and Business). Published models are compiled and smoke-tested first; if one fails at runtime, that request falls back to the built-in model.
The built-in model: Request → Risk score → Agent → Signup policy (first hit) → Response. Templates: Sign-up trust rules + Agent (default) and Rules only (no LLM call).
{
"id": "agent",
"type": "customNode",
"name": "Agent (typesafe/jev-1.13)",
"content": {
"kind": "agent",
"config": { "minScore": 0, "timeoutMs": 6000, "model": null }
}
}minScore > 0 asks Agent only about riskier sign-ups; model: null uses the workspace model (default typesafe/jev-1.13). Contract: the last node outputs decision and reason; score, message and ai are optional.
Signals
Every field below is addressable from a decision table column.
| Group | Fields |
|---|---|
email | normalized, domain, valid, disposable, freemail, webmail, hasMx (true / false / null = unknown), tempPattern, plusAlias, digitRatio, localRandom, subdomain, generalInbox, digitRun3, university, student, gmailDotPattern |
domain | allowListed, blockListed, blockReason, knownGood (a paying customer’s domain), company (not webmail), throwaway |
ip | present, version, private, tor |
name | present, random, oneWord, inEmail, initialMatchesEmail, isCompanyOfDomain, fitsUniversityEmail, junk, mashed |
velocity | ipAttempts10m, ipAttempts1h, ipDenials24h, sameNetwork24h, domainAccounts24h, domainAccounts30d, domainDenials30d, sameName7d, sameNamePasswordSignups30d, emailPriorSignups — per workspace and key mode |
bot | uaMissing, uaHeadless, uaAutomation, uaCrawler, tooFast, honeypotFilled, timeToSubmitMs |
captcha | configured, provided, valid |
request | provider, passwordSignup, country, countryBlocked, timeZone, language |
score | Computed by the "Risk score" expression node |
ai | verdict ("real" | "suspicious" | null), confidence, signal, sureConfidence — after the Agent node |
Raw IPs are never stored — they are HMAC-hashed per workspace, IPv6 grouped by /64.
Review queue
- Held-back sign-ups appear in the queue with Agent’s opinion, the appeal (if any) and what happened after sign-up.
- Reviewers (role reviewer and above) approve or reject, optionally allow / block the whole domain.
- Resolution is atomic — one webhook per evaluation, even with concurrent reviewers and Agent on appeal.
- Held-back sign-ups wait until someone decides; optionally auto-resolve after N hours (Settings → Review queue, default off).
Webhooks
| Event | When |
|---|---|
signup.allowed | Sign-up passed. |
signup.denied | Clear abuse was refused. |
signup.review_required | Held back at sign-up (rules 1–13, elevated risk). |
signup.held_back | An allowed sign-up was held back later (rule 10). |
signup.appealed | The user appealed and Agent could not approve; a person decides. |
signup.approved | Approved by a reviewer or by Agent on appeal. |
signup.rejected | Rejected by a reviewer. |
POST https://yourapp.com/webhooks/cyberfence
CyberFence-Event: signup.approved
CyberFence-Delivery: whd_…
CyberFence-Signature: t=1733140000,v1=<hex HMAC-SHA256(secret, "<t>.<rawBody>")>
{ "id": "evt_…", "type": "signup.approved", "created": "…", "workspaceId": "ws_…",
"data": { "evaluation": { "id": "evl_…", "email": "…", "status": "approved", "reason": "rule3_one_word_name",
"externalUserId": "usr_42", "aiReview": {…}, "appeal": {…}, "postSignup": {…}, "isCustomer": false } } }import { verifyWebhook } from '@cyberfence/node';
app.post('/webhooks/cyberfence', express.raw({ type: 'application/json' }), async (req, res) => {
const event = verifyWebhook(req.body, req.headers['cyberfence-signature'], process.env.CYBERFENCE_WEBHOOK_SECRET!);
const ev = event.data.evaluation!;
if (event.type === 'signup.approved') await db.users.activate(ev.externalUserId!);
if (event.type === 'signup.held_back') await db.users.holdBack(ev.externalUserId!);
if (event.type === 'signup.rejected') await db.users.disable(ev.externalUserId!);
res.sendStatus(200);
});- Verify against the raw body. Signatures older than 5 minutes are rejected (replay protection).
- Respond 2xx quickly. Failures are retried 8 times with backoff (10s → 24h, ~45h total); see the delivery log to replay.
- In production, endpoints must be https and must not resolve to private addresses.