Enforce an attack's rule
const url = 'https://api.nsin.ir/domains/example.com/attacks/1/enforce';const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.nsin.ir/domains/example.com/attacks/1/enforce \ --header 'Authorization: Bearer <token>'Switches the attack’s rule from dry run to enforce (and on), and marks
the attack mitigating. At most 3 attack rules are on per domain; the
oldest is switched off to make room. Requires rules.edit.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The domain name (for example example.com) — not a numeric id.
Example
example.comResponses
Section titled “ Responses ”The attack.
object
volume: a flood, far more requests than usual. behaviour: the
traffic suddenly behaves differently (for example no CSS/JS/image
requests, no cookies, one HTTP version only), even at normal
volume. A behaviour attack ends after 30 minutes without the change.
What changed (behaviour attacks; empty for floods), strongest first, at most 8.
object
share: 0–1 of requests. ratio: requests per path or per IP.
The usual value at this hour of day.
The value during the attack.
How unusual the change is (larger = stronger).
Highest requests per minute seen.
Usual requests per minute for this hour of day.
object
object
The cookie name for cookie; else empty.
Share of the attack’s requests with this value (0–1).
Share of normal requests with this value (0–1).
The rule’s conditions as text; empty without a rule.
reference_day: the same time on the most normal recent day (behaviour attacks).
Share of the attack the rule matches.
Share of normal requests the rule would have hit; -1 = unknown.
object
"", “user:
Example
{ "status": "detected", "kind": "volume", "drift": [ { "feature": "asset", "group": "assets", "unit": "share" } ], "signature": { "features": [ { "field": "ja4h" } ], "baseline_window": "hour_before" }, "rule": { "action_mode": "enforce" }}Missing, malformed, revoked or expired API key. (A valid key whose
account has been deactivated gets 403 account is inactive instead.)
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Examples
{ "error": "invalid API key"}The key is read-only, your role on the domain lacks the required permission, or the domain’s plan does not include the feature.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}No such attack on this domain.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The attack has no rule, or it has ended.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The key exceeded its request budget (300 requests per minute by default).
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Examples
{ "error": "rate limit exceeded"}