Firewall & AI detection
Refuse fraudulent, malformed and brute-force sends before they cost you anything.
Every send passes three layers, in order. Each one only sees what the one before let through, and a refused send is never delivered or charged.
| Layer | Decides on | Where |
|---|---|---|
| Rules | Caller IP, country, user agent; destination email, domain, number, prefix, carrier, pattern | Console → Firewall → Rules |
| Send limits | How many sends per destination, IP, prefix or carrier in a window | Console → Firewall → Send limits |
| AI detection (Pro) | Invalid destinations, brute-force bursts and abuse patterns, judged by Jev | Console → Firewall → AI detection |
The firewall has three modes: Enforce refuses with 403, Monitor only
records what it would have refused (guard.would_block in the audit log), and
Off. Start new rules in Monitor.
End users behind your server
When your server calls send() for a user, pass who they are so caller
rules, per-IP send limits and AI detection judge them rather than your server:
await verifyme.send({
target: "+85512345678",
client: { ip: userIp, user_agent: req.headers.get("user-agent") ?? undefined },
})userIp must come from your own trusted proxy setup — never a raw
X-Forwarded-For. Rules scoped to End users run on it; rules scoped to
API still judge your server, so forwarding only adds checks. A private or
loopback address is ignored. The Better Auth plugin
does this for you.
Pattern rules
When a prefix is not precise enough, match the destination with a regular expression. Patterns use RE2 syntax, which runs in linear time. They are matched against the canonical target:
- a phone number in E.164 (
+85512345678), whatever the caller sent; - an email address in lower case, without its
+tag(ann@example.com).
| Goal | Kind | Action | Pattern |
|---|---|---|---|
| Accept only 8–9 digit Cambodian numbers | Phone pattern | Allow | ^\+855\d{8,9}$ |
| Accept only North American numbers | Phone pattern | Allow | ^\+1\d{10}$ |
| Refuse numbers too short to exist | Phone pattern | Deny | ^\+\d{7,9}$ |
| Refuse throwaway mail domains | Email pattern | Deny | @(mailinator|tempmail)\. |
| Refuse machine-made local parts | Email pattern | Deny | ^[a-z0-9]{24,}@ |
Deny always wins. Once a destination group has any allow rule, a phone (or email) must match one of the allow rules to be sent. Use Firewall → Test a request to try a target before you save.
Countries
Firewall → Countries lists every country with its last 30 days of sends,
verification rate and cost. Switch on the countries you serve and every other
destination is refused with 403 before it costs anything — the simplest
defence against toll fraud. Each mode has its own list; a new business starts
with only the country it signed up from, in live mode, and test mode open.
Fraud Shield
Fraud Shield stops SMS pumping without any rules. If fewer than 20% of at
least 30 codes sent to a number range (such as +85512…) in the last hour are
verified, sends to that range pause for an hour. Your API gets 403 for those
sends. Numbers that have verified before still get through.
Change the percentage, or set it to 0 to turn the shield off, in Firewall → Fraud Shield. The same page lists paused ranges and lets you resume one. The shield follows the firewall mode, so in Monitor it only logs what it would have paused.
AI detection
AI detection is available on the Pro plan once your platform has it switched on. Turn it on in Firewall → AI detection. Start in Monitor, read what it flags, then switch to Enforce.
It works in two stages, and the cheap stage runs first:
- Free local checks, with no model call:
- a destination that cannot be real: malformed, too short, a subscriber number
that is one repeated digit or a straight run (
1111111,1234567), or an email domain with no mail server; - brute force: too many sends to one destination, from one IP, or into one 10,000-number range within ten minutes.
- a destination that cannot be real: malformed, too short, a subscriber number
that is one repeated digit or a straight run (
- Jev: TypeSafe's decision model judges the rest from the destination, the caller (IP, country, user agent) and recent activity. It tells SMS pumping, enumeration, bots, disposable addresses and harassment apart from a genuine user.
To keep costs down, a destination that verified successfully is trusted for 30 days, and a verdict is reused for ten minutes for the same destination and caller. If Jev is slow or unreachable, the send goes ahead: your rules and send limits still apply.
Refusals appear in Firewall → Overview and in the audit log as
guard.ai_blocked. In Monitor mode they appear as guard.ai_would_block. Both
carry the request's trace_id.
Smart routing with AI
A routing rule with the AI (Jev) strategy lets Jev choose which provider in the rule delivers first, based on the destination's country, carrier or mail domain and each provider's cost, health and latency. Jev can only reorder the providers you listed, and never puts an unhealthy one first. Failover still walks the rest of the list. When AI detection is unavailable, the rule behaves like Cheapest first.
Your own key
A business can add its own TypeSafe API key under AI detection. That key is used instead of the platform's, and calls are billed to your TypeSafe account. Saving a key turns on Monitor if AI detection was off.