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

/security/modsec/rules/{id}

First published 19 Nov 20260.2.30Unchanged since publication

Update a custom ModSecurity rule

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

Provide at least one of text, note, or enabled. The API returns 400 if none is supplied or if id, text, or note fails validation. If text specifies a different rule number, that number must be unused by other custom rules and becomes the rule's new id. Numbers from 90000 onward are reserved for UrbeStack and the bundled rule set.

Enabling a rule or replacing the text of a rule that will remain enabled requires UrbeStack to manage ModSecurity and Apache to load the module. UrbeStack tests Apache's configuration before applying the change. If Apache rejects it, UrbeStack keeps the previous rule and returns Apache's error. You can disable a rule even if Apache would reject its text. The response contains the updated rule.

As a command

Run as root on the server

Parameters

idpath ·integer, 1 to 89999Required
Number of the custom rule to delete.

Request body

JSON· 3 fields
enabledboolean
Whether to enable or disable the rule. Use true to enable it or false to disable it.
notestring, up to 200 characters
Single-line description of the rule's purpose, up to 200 characters, with no ASCII control characters. Use an empty string to clear the note.
textstring, up to 8000 characters
One SecRule or SecAction directive or one complete chain in ModSecurity syntax, up to 8000 characters. Put id:N on the first directive with a number from 1 to 89999, and include the chain action on each directive in a chain except the last.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PATCH "$API/security/modsec/rules/1" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "note": "added by hand",
    "text": "text"
  }'
Response · 200 OK
{
  "apache": "text",
  "created_at": "2026-09-09T10:15:00Z",
  "created_by": "text",
  "enabled": true,
  "files_changed": 1,
  "note": "added by hand",
  "refuses": true,
  "rule": 1,
  "text": "text",
  "updated_at": "text",
  "updated_by": "text"
}

Errors

9 errors, each a status and a sentence
400--enabled is on or off
400A rule is named by its number
400Nothing to set: give text, note or enabled
400Nothing to set: give the text, what it is for, or on or off
400Say which rule: --rule NUMBER
400note is one line of up to 200 characters
400text is the rule, as the engine reads it, up to 8000 characters
401Authentication required
409Rule <new.rule_id> is already another custom rule
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-rules-id/