Get your free beta license ↗
API operation · domains group
PATCH

/domains/{name}/modsec

First published 19 Nov 20260.2.30Unchanged since publication

Set a domain's ModSecurity mode or its owner's choice

Who may call it
AdministratorResellerCustomer
Token scope, any of
domainsall
Answers200 OK

Supply mode, choice, or both. The domain's owner, the reseller who manages the owner, and administrators can set choice. Only administrators can set mode. The API returns 403 if another caller supplies mode and 400 if neither field is supplied or a mode value is invalid.

If the owner has a choice, the weaker of that choice and the administrator's mode for the domain takes effect. Otherwise, the administrator's mode applies.

UrbeStack saves the settings and, when modsec.managed is enabled, updates the domain's Apache virtual host and ModSecurity configuration as needed. UrbeStack tests the Apache configuration only if it changes and reloads Apache if the test passes. If Apache rejects the configuration, UrbeStack restores the previous configuration and discards the changes. The response contains the same details as GET /domains/{name}/modsec.

As a command

Run as root on the server

Parameters

namepath ·DomainNameRequired

Request body

JSON· 2 fields
choicestring, one of off, logging, blocking or null
Owner's ModSecurity mode, accepted only while the administrator's mode for the domain is logging or blocking and the choice is no stronger. Both null and a value equal to the administrator's mode clear the choice.
modestring, one of off, logging, blocking or null
Administrator's ModSecurity mode for the domain, which can raise or lower the server mode. Use null to make the domain inherit the server mode again.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PATCH "$API/domains/example.com/modsec" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "choice": "off",
    "mode": "off"
  }'
Response · 200 OK
{
  "allowed": "off",
  "choice": {
    "at": "text",
    "mode": "off"
  },
  "customized": true,
  "disabled_rules": {
    "by_owner": 1,
    "max": 1,
    "total": 1
  },
  "domain": "example.com",
  "in_force": "off",
  "locked": true,
  "managed": true,
  "own": {
    "at": "text",
    "by": "text",
    "mode": "off"
  },
  "owner": "text",
  "server": {
    "by_hand": "off",
    "mode": "off"
  }
}

Errors

11 errors, each a status and a sentence
400A ModSecurity mode is off, logging or blocking
400Domain name required
400Domain name too long
400Invalid domain name
400Nothing to set: give a mode, a choice or both
400Nothing to set: give mode, choice or both
401Authentication required
403A domain's own mode is set by an administrator
404Domain '<name>' not found
409ModSecurity is off for <name> by the administrator, so its owner's choice would change nothing
409The administrator allows up to <NAMES>{<base>} for <name>; its owner may lower that, not raise it
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.2.30 on 19 Nov 2026.
urbestack.com/docs/api/patch-domains-name-modsec/