IP rules: block or allow requests by IP address
When an attack comes from one place, block that place. IP rules are your own list of IP addresses and ranges: a check that comes from a blocked IP ends at once, for free, on every endpoint, for your account and no one else’s.
What a rule does
- Block. Every check from a covered IP ends in the free gate with the reason
ip_blocklisted: verdictinvalid, bounce probability 0.90 with interval [0.72, 0.97], no provider called, no AI check,cost_usd: 0./v1/checkanswerspasses: false. On/v1/screenit addsip_blocklisted, which meansreview. A blocked check counts exactly like a domain block: one verification on/v1/verifyand/v1/decide, nothing on/v1/check. - Allow. An exception. An allowed IP is never blocked by a wider range on your blocklist. It changes nothing else: the address is still checked as usual, and no reason is added.
The answer is a normal 200, not an HTTP error. Act on reason, recommendation or your policy’s decision, the same as for any other blocked check. The person on the other end learns nothing from a status code.
Which IP is matched
The IP the request’s row in Logs shows:
- The visitor’s IP when your server sends it as
context.client.ipon/v1/verify,/v1/decide,/v1/checkor/v1/screen, or when the check comes from the browser widget. - Otherwise the IP that called Sortance: for a server-to-server call, your server. Blocking that blocks every check your server makes, so send
context.client.ipif you want to block visitors.
Bulk jobs have no requester and never consult IP rules. /v1/enrich runs no gate and does not either.
Precedence
- Broken syntax (
syntax_invalid) still reports first - Your IP blocklist
- Your address blocklist, then address allowlist
- Your domain blocklist, then domain allowlist
- Sortance’s global tiers
An IP block outranks an address you allowed: the rule is about who is asking, not which address they typed. Between your IP blocklist and allowlist, the most specific entry wins: block 198.51.100.0/24 and allow 198.51.100.20, and only that one address gets through. An entry is on one list or the other, never both.
Routes
Same key as every other call. These are configuration, not verification: they do not count against your monthly quota, and share the 600-a-minute rate limit. Changing a list needs the member role or above; any role can list and check.
| Method | Path | Does |
|---|---|---|
GET | /v1/ips/blocklist | Your blocked IPs and ranges: { rule, ips: [{ ip, note, created_at }], count }. |
GET | /v1/ips/allowlist | Your allowed IPs and ranges, same shape. |
POST | /v1/ips/blocklist | Add to the blocklist: { ips: string[], note?: string }. |
POST | /v1/ips/allowlist | Add to the allowlist, same body. |
DELETE | /v1/ips/blocklist | Remove from the blocklist: { ips: string[] }. |
DELETE | /v1/ips/allowlist | Remove from the allowlist, same body. |
POST | /v1/ips/check | What would happen to a request from one IP on your account: { ip }. |
Add
curl -X POST https://api.sortance.com/v1/ips/blocklist \
-H "Authorization: Bearer $SORTANCE_KEY" \
-H "Content-Type: application/json" \
-d '{"ips":["203.0.113.7","198.51.100.0/24"],"note":"credential stuffing"}'{ "rule": "block", "added": 2, "moved": 0, "unchanged": 0, "total": 2 }Adding an entry to one list takes it off the other; moved counts those. An entry already there keeps its date, and its note unless you send a new one. total is your IP rules across both lists.
List
curl https://api.sortance.com/v1/ips/blocklist \
-H "Authorization: Bearer $SORTANCE_KEY"{
"rule": "block",
"ips": [
{ "ip": "198.51.100.0/24", "note": "credential stuffing", "created_at": 1791400000 },
{ "ip": "203.0.113.7", "note": "credential stuffing", "created_at": 1791400000 }
],
"count": 2
}Remove
curl -X DELETE https://api.sortance.com/v1/ips/blocklist \
-H "Authorization: Bearer $SORTANCE_KEY" \
-H "Content-Type: application/json" \
-d '{"ips":["203.0.113.7"]}'DELETE removes from the list named in the path only.
Check one IP
curl -X POST https://api.sortance.com/v1/ips/check \
-H "Authorization: Bearer $SORTANCE_KEY" \
-H "Content-Type: application/json" \
-d '{"ip":"198.51.100.9"}'{
"ip": "198.51.100.9",
"org_rule": "block",
"matched": { "ip": "198.51.100.0/24", "rule": "block", "note": "credential stuffing", "created_at": 1791400000 },
"effective": "blocked"
}Takes one address, not a range. matched is the most specific entry that applied. effective is one of:
| effective | Means |
|---|---|
blocked | The most specific matching entry is on your blocklist. Every check from this IP ends with ip_blocklisted. |
allowed | The most specific matching entry is on your allowlist: a wider blocked range does not apply to this IP. |
none | No entry covers this IP. Checks run as usual. |
What counts as an entry
A single IPv4 or IPv6 address, or a CIDR range. Entries are stored in a canonical form: host bits are zeroed (203.0.113.77/24 is stored as 203.0.113.0/24), a full-length prefix is the bare address, IPv6 is lower-case and compressed, and an IPv4-mapped IPv6 address is stored as IPv4. A bad entry fails the whole request: a 400 lists every bad entry by its position in your array, and nothing is written.
{ "error": {
"code": "invalid_request",
"message": "2 entries are not a usable IP address or range. ...",
"trace_id": "...",
"invalid": [
{ "index": 1, "value": "10.0.0.0/16", "reason": "not_public" },
{ "index": 2, "value": "203.0.0.0/8", "reason": "range_too_wide" }
]
} }| reason | When |
|---|---|
invalid_ip | Not an IP address or a CIDR range (203.0.113.7, 203.0.113.0/24, 2001:db8::1, 2001:db8:1::/48). |
range_too_wide | The range is wider than /16 (IPv6: /32). |
not_public | A private, loopback, link-local, carrier-grade NAT, multicast, reserved or unspecified address. Usually a sign your server is passing its own internal IP. |
address_not_allowed | The entry contains @. IP rules take IPs and ranges, and the value is not echoed back. |
not_a_string | The entry is not a string. |
- At most 1,000 entries per request, and 10,000 across both lists per account, counted separately from domain and address rules.
- Ranges go no wider than /16 for IPv4 and /32 for IPv6, so one entry cannot switch off a whole provider or every user behind a proxy.
- A
noteis optional, up to 200 characters, and a note that contains an email address is refused.
When a change takes effect
The same as domain rules: each API instance remembers an account’s rules for 30 seconds, so a change usually applies everywhere within a minute. /v1/ips/check reads the stored rules directly. If the rules cannot be read during a check, the check runs as if you had none, rather than failing.
In the dashboard
Rules → IP addresses lists both lists, adds and removes in bulk (paste one per line), and checks one IP. Every row in Logs has “Allow or block”: an IPv4 row offers that IP, an IPv6 row its /64 network, because a device rotates addresses inside it and a single-address block would not hold. The dialog warns before you block the IP of your own server.
The MCP tools list_blocklist and update_blocklist take kind: "ip" (see MCP).
A policy rule can already test request.ip against ranges, or request.country and request.asn, and send a request to review instead of rejecting it. IP rules are the one-click version: they act on every check without a policy edit.