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

/security/jails/{name}

First published 3 Oct 20260.1.0Unchanged since publication

Update a ban rule

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

Supply at least one setting to change. Use enabled to turn a rule on or off. Set scope to all for all ports, mail for mail ports, or web for web ports.

The tries field sets how many matches for one IP address within window trigger a ban. It accepts 1 to 1000. The window field accepts 10 seconds to 30 days, and bantime accepts 10 seconds to 366 days. Use whole seconds or a duration with a unit, such as 10s, 10m, 1h, 2d, or 1w.

Only custom rules accept changes to log and pattern. Supply the absolute path to an existing log file in log. Path components can contain letters, digits, dots, hyphens, and underscores. A .. component is invalid. Supply a single-line regular expression of 1 to 500 printable ASCII characters in pattern, with <HOST> where the IP address appears. The API returns 400 for invalid name, log path syntax, pattern, tries, window, bantime, or scope values.

As a command

Run as root on the server

Parameters

namepath ·string, matching ^[a-z0-9][a-z0-9-]{0,31}$Required

Request body

JSON ·JailUpdate· 7 fields
bantimestring, up to 16 characters
Ban duration expressed in seconds or with a unit suffix, as in 10m, 1h, 2d, or 1w.
enabledboolean
logstring, up to 255 characters
patternstring, up to 500 characters
scopestring, one of all, mail, web
Scope of the ban. The value all blocks all traffic from the IP address. The values mail and web limit the ban to the ports the rule protects.
triesinteger, 1 to 1000
windowstring, up to 16 characters
Time window during which failures count toward a ban, expressed in seconds or with a unit suffix, as in 10m, 1h, 2d, or 1w.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PATCH "$API/security/jails/alice" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "bantime": "text",
    "enabled": true,
    "log": "",
    "pattern": "text",
    "scope": "all",
    "tries": 1,
    "window": "text"
  }'
Response · 200 OK
{
  "jail": {
    "active": true,
    "bans_week": 1,
    "bantime": 1,
    "created_at": "2026-09-09T10:15:00Z",
    "enabled": true,
    "filter": "text",
    "inactive_reason": "text",
    "journal": "text",
    "log": "",
    "name": "alice",
    "pattern": "text",
    "scope": "all",
    "service": "text",
    "shipped": true,
    "tries": 1,
    "what": "text",
    "window": 1
  }
}

Errors

16 errors, each a status and a sentence
400'<n>' is a name fail2ban keeps for itself
400<what> is a number of seconds, or with a unit: 10m, 1h, 2d, 1w
400<what> must be between
400A log is an absolute path of letters, digits, dots, dashes and underscores
400A log path may not contain ..
400A pattern is 1 to 500 printable characters on one line
400A pattern needs <HOST> where the address is
400A rule name is 1 to 32 lowercase letters, digits and dashes
400A rule shipped with the panel keeps its log and pattern; its switch, numbers and scope are yours
400A scope is all, mail or web
400Invalid boolean
400Nothing to change
400The log <set.log> does not exist
400The pattern is not a regular expression:
400Tries must be a number from 1 to 1000
401Authentication required
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/patch-security-jails-name/