Apply a one-click fix
const url = 'https://api.nsin.ir/recommendations/fix?domain=example.com';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"apply":"waf_enforce"}'};
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/recommendations/fix?domain=example.com' \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "apply": "waf_enforce" }'Runs the fix a recommendation offers in action.apply (or alt.apply).
The server re-reads the problem first: if it is gone the answer is
already_done, and if the item no longer offers this fix the answer is
409 with the fresh list. Otherwise it applies the change through the
same code as the feature’s own endpoint, tells the edges, checks that
the change took effect, and returns the domain’s new checklist.
Fixes: attack_enforce, attack_ignore, under_attack_on (6-hour
timer), under_attack_off, auto_attack_rules_on/_off,
auto_under_attack_on/_off, waf_restore, waf_enable,
waf_enforce, waf_dry_run, login_rate_limit (a per-IP limit of 10
POSTs a minute on wp-login.php and xmlrpc.php, answered with a check),
login_rate_limit_off (send the rule_id from the fix’s undo; a rule
edited since is left alone). The _off and waf_dry_run fixes are
undos and need no recommendation.
Needs the permission of the change itself: rules.edit for attack and
WAF fixes, domain.settings for the switches.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Query Parameters
Section titled “Query Parameters ”The domain name (for example example.com). These endpoints take the
domain as a query parameter rather than a path segment.
Example
example.comRequest Body required
Section titled “Request Body required ”object
The fix name from the recommendation’s action.
Only for login_rate_limit_off: the rule id from the fix’s undo.
Example
{ "apply": "waf_enforce"}Responses
Section titled “ Responses ”Applied, or already done.
object
Present when the change can be undone in one call.
object
Send back with the undo (login_rate_limit_off).
The domain’s checklist after the change.
object
Example
{ "result": "applied"}Missing domain or apply, or an unknown fix.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}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"}Missing permission, or the plan does not include it (upgrade_required).
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The item no longer offers this fix (the attack ended, someone else fixed it). data is the fresh list.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The fix failed or did not take effect.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}