# POST /security/jails/{name}/test

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the security group.

Test a ban rule's filter against a log

- Who may call it: administrator
- Token scope, any of: security, all
- Answers: 200 OK

UrbeStack runs fail2ban-regex with the rule's filter against up to 1,000 of the most recent lines from its configured log file or systemd journal. Supply log to use a different file. The response reports the total, matched and missed line counts and includes up to three matching lines.

The test has a 330-second timeout. UrbeStack returns 400 if name or log is invalid or if name is one of the reserved names default and includes.

## As a command

- [urbestack-jail-test](https://urbestack.com/docs/commands/urbestack-jail-test.md): Tests a ban rule or a regular expression against up to 1,000 of the most recent lines from a log file or systemd journal.

## Parameters

- `name` (path, string, matching ^[a-z0-9][a-z0-9-]{0,31}$, required)

## Request body

JSON.

- `log` (string, up to 255 characters): Absolute path to an alternate log file. Use letters, digits, dots, dashes and underscores within path components, with no parent-directory (..) components.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/security/jails/alice/test" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "log": ""
  }'
```

Response, 200 OK:

```
{
  "examples": [
    "text"
  ],
  "filter": "text",
  "lines": 1,
  "log": "",
  "matched": 1,
  "missed": 1
}
```

## Errors

- 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 
- 400: A log is an absolute path of letters, digits, dots, dashes and underscores
- 400: A log path may not contain ..
- 400: A pattern is 1 to 500 printable characters on one line
- 400: A pattern needs <HOST> where the address is
- 400: A rule name is 1 to 32 lowercase letters, digits and dashes
- 400: A scope is all, mail or web
- 400: Give a rule name, or a log and a pattern
- 400: The pattern is not a regular expression: 
- 400: Tries must be a number from 1 to 1000
- 400: fail2ban-regex could not run the test: <why>
- 401: Authentication required
- 404: <source> does not exist
