Enforce an attack's rule
Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.
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.
Path parameters
- domainstringrequiredpath
The domain name (for example
example.com) — not a numeric id. - attackIdintegerrequiredpath
Responses
200The attack.
Content type: application/json
- idinteger
- domain_idinteger
- domain_namestring
- statusstringOne of:
"detected""mitigating""ended""ignored" - kindstring
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.One of:"volume""behaviour" - driftarray of AttackDrift
What changed (behaviour attacks; empty for floods), strongest first, at most 8.
Item fields
- featurestringOne of:
"asset""html""api""no_referer""no_cookie""many_cookie""s2""s3""s4""s404""s5""post""other_method""h1""h2""h3""bot_low""bot_high""req_per_path""req_per_ip" - groupstringOne of:
"assets""cookies""status""protocol""bot""paths""ips" - unitstring
share: 0–1 of requests.ratio: requests per path or per IP.One of:"share""ratio" - normalnumber
The usual value at this hour of day.
- nownumber
The value during the attack.
- znumber
How unusual the change is (larger = stronger).
- started_atstring (date-time)
- ended_atstring (date-time) | null
- calm_sincestring (date-time) | null
- peak_rpminteger
Highest requests per minute seen.
- baseline_rpmnumber
Usual requests per minute for this hour of day.
- signatureobject
Fields
- featuresarray of AttackSignatureFeature
Item fields
- fieldstringOne of:
"ja4h""ja4""user_agent""cookie""header_set_hash""path""method""asn""country" - keystring
The cookie name for
cookie; else empty. - valuestring
- coveragenumber
Share of the attack's requests with this value (0–1).
- baseline_sharenumber
Share of normal requests with this value (0–1).
- expressionstring
The rule's conditions as text; empty without a rule.
- attack_requestsinteger
- baseline_requestsinteger
- baseline_windowstring
reference_day: the same time on the most normal recent day (behaviour attacks).One of:"hour_before""day_before""reference_day""none"
- coveragenumber
Share of the attack the rule matches.
- fp_estimatenumber
Share of normal requests the rule would have hit; -1 = unknown.
- rule_idinteger | null
- ruleobject | null
Fields
- idinteger
- namestring
- enabledboolean
- action_modestringOne of:
"enforce""dry_run"
- enforced_bystring
"", "user:
" or "admin: ". - notestring
- created_atstring (date-time)
- updated_atstring (date-time)
{
"id": 0,
"domain_id": 0,
"domain_name": "string",
"status": "detected",
"kind": "volume",
"drift": [
{
"feature": "asset",
"group": "assets",
"unit": "share",
"normal": 0,
"now": 0,
"z": 0
}
],
"started_at": "2026-01-01T00:00:00Z",
"ended_at": "2026-01-01T00:00:00Z",
"calm_since": "2026-01-01T00:00:00Z",
"peak_rpm": 0,
"baseline_rpm": 0,
"signature": {
"features": [
{
"field": "ja4h",
"key": "string",
"value": "string",
"coverage": 0,
"baseline_share": 0
}
],
"expression": "string",
"attack_requests": 0,
"baseline_requests": 0,
"baseline_window": "hour_before"
},
"coverage": 0,
"fp_estimate": 0,
"rule_id": 0,
"rule": {
"id": 0,
"name": "string",
"enabled": true,
"action_mode": "enforce"
},
"enforced_by": "string",
"note": "string",
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z"
}401Missing, malformed, revoked or expired API key. (A valid key whose
account has been deactivated gets 403 account is inactive instead.)
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "invalid API key"
}403The key is read-only, your role on the domain lacks the required permission, or the domain's plan does not include the feature.
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "read-only API key"
}404No such attack on this domain.
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "read-only API key"
}409The attack has no rule, or it has ended.
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "read-only API key"
}429The key exceeded its request budget (300 requests per minute by default).
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "rate limit exceeded"
}Example request
curl -X POST "https://api.nsin.ir/domains/example.com/attacks/0/enforce" \
-H "Authorization: Bearer $NSIN_API_KEY"