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

/security/jails/test

First published 3 Oct 20260.1.0Unchanged since publication

Test an unsaved ban rule pattern against a log file

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

Supply the absolute log file path in log and a single-line regular expression of 1 to 500 printable ASCII characters in pattern, with <HOST> where the IP address appears. Path components can contain letters, digits, dots, hyphens, and underscores. The API returns 400 for an invalid path, including a .. component, or an invalid pattern.

UrbeStack runs fail2ban-regex on up to 1,000 of the most recent lines. The response includes the total, matched, and missed line counts and up to three matching lines. The test has a timeout of 330 seconds.

As a command

Run as root on the server

Request body

JSON ·JailTest· 2 fields
logstring, up to 255 charactersRequired
patternstring, up to 500 charactersRequired

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X POST "$API/security/jails/test" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "log": "",
    "pattern": "text"
  }'
Response · 200 OK
{
  "examples": [
    "text"
  ],
  "filter": "text",
  "lines": 1,
  "log": "",
  "matched": 1,
  "missed": 1
}

Errors

15 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 scope is all, mail or web
400Give a rule name, or a log and a pattern
400The pattern is not a regular expression:
400Tries must be a number from 1 to 1000
400fail2ban-regex could not run the test: <why>
401Authentication required
404<source> does not exist
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/post-security-jails-test/