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

/security/modsec

First published 19 Nov 20260.2.30Unchanged since publication

Change the server's ModSecurity mode or who manages it

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

Provide mode, managed, or both. The API returns 400 if neither field is supplied or either value is invalid. The API also accepts 1 and 0 for managed, meaning true and false respectively. While the administrator manages ModSecurity, UrbeStack saves the mode for use when it takes over.

When UrbeStack manages ModSecurity, it includes OWASP CRS if the server or any domain uses logging or blocking, unless another rule set uses overlapping rule numbers. When a change affects Apache's configuration, UrbeStack tests it and reloads Apache immediately. If Apache rejects the configuration, UrbeStack restores the previous configuration, discards the change, and returns Apache's error.

The response includes the same status information as GET /security/modsec and a set object with the results of the changes.

As a command

Run as root on the server

Request body

JSON· 2 fields
managedboolean
Whether UrbeStack manages ModSecurity. Set true to apply UrbeStack's configuration and queue installation if the module is missing, or false to remove UrbeStack's configuration and return control to the administrator.
modestring, one of off, logging, blocking
Server mode, which defaults to off and disables inspection for domains that follow the server mode. Use logging to inspect every request and log those that would be refused, or blocking to allow matching requests to be refused.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PATCH "$API/security/modsec" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "managed": true,
    "mode": "off"
  }'
Response · 200 OK
{
  "by_hand": {
    "directive": "text",
    "file": "urbestack-panel-20260909T101500Z.json.enc",
    "line": 1,
    "mode": "text"
  },
  "decided": true,
  "disabled_rules": {
    "by_administrators": 1,
    "by_owners": 1,
    "domains": 1,
    "gone": 1,
    "server": 1,
    "total": 1
  },
  "domains": {
    "customized": 1,
    "in_force": {
      "blocking": 1,
      "logging": 1,
      "off": 1
    },
    "lowered": 1,
    "own_mode": 1,
    "total": 1
  },
  "files": {
    "loader": "text",
    "ours": "text",
    "ours_written_at": "text",
    "packaged": "text",
    "yours": "text"
  },
  "installed": true,
  "limits": {
    "request": 1,
    "request_without_files": 1
  },
  "loaded": true,
  "managed": true,
  "mode": "off",
  "mode_set": {
    "at": "text",
    "by": "text"
  },
  "module": {
    "file": "urbestack-panel-20260909T101500Z.json.enc",
    "package": "basic",
    "version": "0.0.1"
  },
  "other_rule_set": {
    "file": "urbestack-panel-20260909T101500Z.json.enc"
  },
  "own_rules": {
    "enabled": 1,
    "file": "urbestack-panel-20260909T101500Z.json.enc",
    "total": 1
  },
  "packaged_active": true,
  "rule_set": {
    "included": true,
    "name": "alice",
    "version": "0.0.1"
  },
  "set": {},
  "state": "managed",
  "wordpress_exclusions": {
    "version": "0.0.1"
  }
}

Errors

33 errors, each a status and a sentence
400'<zone>' is not a zone this machine knows: timedatectl list-timezones names them
400--managed is true or false
400A ModSecurity mode is off, logging or blocking
400A new job is queued or running
400Domain name required
400Domain name too long
400Invalid IPv4 address
400Invalid IPv6 address
400Invalid boolean
400Invalid domain name
400Invalid port
400Invalid setting key
400Job parameters must be an object
400Nothing to set: give --mode, --managed or both
400Nothing to set: give mode, managed or both
400PHP <version> cannot be the default: it is hidden from new choices on this server
400PHP <version> cannot be the default: it is not installed on this server
400Unknown job type
400Unknown setting '<key>'
400jobs.keep_days (<keep>) may not be smaller than jobs.show_days (<show>): a job cannot be shown longer than it is kept; 0 keeps them for good
400managed is true or false
401Authentication required
404Setting '<key>' not found
409<key> cannot take that value: <SECOND>{<k>}{on} <sp> (<k>). <SECOND>{<k>}{move}, or choose another
409<key> cannot take that value: the panel listens on port <port> (panel.port). Move the panel first, or choose another
409<s.subject> cannot take port <port>:
409<s.subject> cannot take port <port>: <why>
409<s.subject> cannot take port <port>: it is the panel's port (panel.port)
409A change is already armed for revert (
409Sharing is required with this license.
409The panel cannot take port <port>:
409The panel cannot take port <port>: <why>
409These are the nameservers of a distribution network with several nodes, and every node lists the same ones. To remove a nameserver or move it to another node, use the actions beside its name on DNS zones › Nameservers & addresses, or urbestack-dns-nameserver
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-security-modsec/