> This page is for Applications Protection.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.humansecurity.com/llms.txt.

# Custom rule operators and conditions

When sending a custom rule in a request body, you **must** specify the `conditionType`, `operator`, `value`, and sometimes the `fieldOption`. Depending on the `conditionType`, there are certain allowed `operator` values, and the data type of `value` and `fieldOption` may change. You **must** adhere to the specifications of these below, or your rule won't properly update.

# Operator definitions

The following allowed `operator` values correspond to operators in the HUMAN platform.

| Operator value | Operator name | Description                                                    |
| :------------- | :------------ | :------------------------------------------------------------- |
| `$eq`          | is            | Checks if the value is equal to the specified value.           |
| `$contains`    | contains      | Checks if the value contains the specified substring.          |
| `$startsWith`  | starts with   | Checks if the value starts with the specified substring.       |
| `$endsWith`    | ends with     | Checks if the value ends with the specified substring.         |
| `$re`          | matches       | Checks if the value matches the specified regular expression.  |
| `$notEndsWith` | not ends with | Checks if the value does not end with the specified substring. |
| `$ne`          | is not        | Checks if the value is not equal to the specified value.       |
| `$in`          | in            | Checks if the value is in the specified list of values.        |
| `$notIn`       | not in        | Checks if the value is not in the specified list of values.    |
| `$exists`      | exists        | Checks if the field exists.                                    |
| `$notExists`   | not exists    | Checks if the field does not exist.                            |

# Supported operators by condition type

The `conditionType` dictates the field upon which the `operator` should act. Each `conditionType` has a certain set of supported `operator` values with specific `value` data types. Be sure to reference the relevant `conditionType` for the available `operator` values.

## User agent (`userAgent`)

| Supported operator | `value` type     | `value` format         |
| :----------------- | :--------------- | :--------------------- |
| `$eq`              | String           |                        |
| `$contains`        | String           |                        |
| `$startsWith`      | String           |                        |
| `$endsWith`        | String           |                        |
| `$re`              | Array of strings | Valid regex expression |

### Examples

```json
{   
    "conditionType": "userAgent",
    "operator": "$re",
    "value": ["Mozilla.*", "Chrome.*"],
}

{
    "conditionType": "userAgent",
    "operator": "$startsWith",
    "value": "Mozilla",
}
```

## Domain (`domain`)

| Supported operator | `value` type     | `value` format         |
| :----------------- | :--------------- | :--------------------- |
| `$endsWith`        | String           |                        |
| `$notEndsWith`     | String           |                        |
| `$eq`              | String           |                        |
| `$ne`              | String           |                        |
| `$re`              | Array of strings | Valid regex expression |

### Examples

```json
{
    "conditionType": "domain",
    "operator": "$notEndsWith",
    "value": ".com",
}

{
    "conditionType": "domain",
    "operator": "$eq",
    "value": "test-site",
}
```

## IP address (`socketIps`)

| Supported operator | `value` type     | `value` format   |
| :----------------- | :--------------- | :--------------- |
| `$eq`              | String           | Valid IP address |
| `$ne`              | String           | Valid IP address |
| `$in`              | Array of strings | Valid IP address |
| `$notIn`           | Array of strings | Valid IP address |

### Examples

```json
{
    "conditionType": "socketIps",
    "operator": "$in",
    "value": [
    "2001:db8:3333:4444:5555:6666:7777:8888",
    "2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF",
    "2.2.2.2",
    "1.1.1.1",
    "128.5.5.5/8",
    "3.3.3.3/4",
    ],
}

{
    "conditionType": "domain",
    "operator": "$ne",
    "value": "128.5.5.5/8",
}

```

## ASN (`socketIpASN`)

| Supported operator | `value` type     | `value` format |
| :----------------- | :--------------- | :------------- |
| `$eq`              | String           | AS`<number>`   |
| `$ne`              | String           | AS`<number>`   |
| `$in`              | Array of strings | AS`<number>`   |
| `$notIn`           | Array of strings | AS`<number>`   |

### Examples

```json
{   
    "conditionType": "socketIpASN",
    "operator": "$notIn",
    "value": ["AS61", "AS21", "AS55"],
}

{   
    "conditionType": "socketIpASN",
    "operator": "$ne",
    "value": "AS61",
}
```

## Path (`path`)

| Supported operator | `value` type     | `value` format         |
| :----------------- | :--------------- | :--------------------- |
| `$startsWith`      | String           |                        |
| `$endsWith`        | String           |                        |
| `$contains`        | String           |                        |
| `$eq`              | String           |                        |
| `$re`              | Array of strings | Valid regex expression |

### Examples

```json
{
    "conditionType": "path",
    "operator": "$startsWith",
    "value": "/login",
}

{ 
    "conditionType": "path",
    "operator": "$re",
    "value": ["\/login.*", "\/sign-.*"],
}
```

## Query parameter (`queryParam`)

> **Warning**
>
> The `queryParam` condition also requires the `fieldOption` parameter, as described below.

| Supported operator | `fieldOption` type | `value` type | `value` format         |
| :----------------- | :----------------- | :----------- | :--------------------- |
| `$exists`          | String             |              |                        |
| `$notExists`       | String             |              |                        |
| `$in`              | String             | String       |                        |
| `$notIn`           | String             | String       |                        |
| `$re`              | Array of strings   | String       | Valid regex expression |

### Examples

```json
{   
    "conditionType": "queryParam",
    "fieldOption": "param1",
    "operator": "$exists",
}

{   
    "conditionType": "queryParam",
    "fieldOption": "param2",
    "operator": "$re",
    "value": ["value", "value2"],
}
```

## Header (`header`)

> **Warning**
>
> The `header` condition also requires the `fieldOption` parameter, as described below.

| Supported operator | `fieldOption` type | `value` type | `value` format         |
| :----------------- | :----------------- | :----------- | :--------------------- |
| `$exists`          | String             |              |                        |
| `$notExists`       | String             |              |                        |
| `$in`              | String             | String       |                        |
| `$notIn`           | String             | String       |                        |
| `$re`              | Array of strings   | String       | Valid regex expression |

### Examples

```json
{   
    "conditionType": "header",
    "operator": "$exists",
    "fieldOption": "header-1",
}

{   
    "conditionType": "header",
    "fieldOption": "header-1.1",
    "operator": "$notIn",
    "value": ["value1", "value2"],
}
```

## HTTP method (`httpMethod`)

| Supported operator | `value` type | `value` options                                                                |
| :----------------- | :----------- | :----------------------------------------------------------------------------- |
| `$in`              | String       | "GET", "POST", "DELETE", "PATCH", "PUT", "HEAD", "OPTIONS", "CONNECT", "TRACE" |
| `$notIn`           | String       | "GET", "POST", "DELETE", "PATCH", "PUT", "HEAD", "OPTIONS", "CONNECT", "TRACE" |

### Examples

```json
{ 
    "conditionType": "httpMethod",
    "operator": "$in",
    "value": ["GET", "POST"],
}
```

## Device type (`deviceType`)

| Supported operator | `value` type | `value` options                            |
| :----------------- | :----------- | :----------------------------------------- |
| `$eq`              | String       | "desktop", "mobile", "mobile_api", "other" |
| `$in`              | String       | "desktop", "mobile", "mobile_api", "other" |

### Examples

```json
{   
    "conditionType": "deviceType",
    "operator": "$eq",
    "value": "desktop",
}

{
    "conditionType": "deviceType",
    "operator": "$in",
    "value": ["desktop", "mobile_api"],
}
```

## Country (`country`)

| Supported operator | `value` type | `value` options    |
| :----------------- | :----------- | :----------------- |
| `$in`              | String       | Valid country code |
| `$notIn`           | String       | Valid country code |

### Examples

```json
{
    "conditionType": "country",
    "operator": "$notIn",
    "value": ["IR"],
}

{   
    "conditionType": "country",
    "operator": "$in",
    "value": ["US", "UK"],
}
```

## Custom parameter (`customParam`)

> **Warning**
>
> The `customParam` condition also requires the `fieldOption` parameter, as described below.

| Supported operator | `fieldOption` options                                                                                                                                                     | `value` type     | `value` format         |
| :----------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------- | :--------------------- |
| `$exists`          | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" |                  |                        |
| `$notExists`       | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" |                  |                        |
| `$eq`              | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" | String           |                        |
| `$ne`              | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" | String           |                        |
| `$in`              | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" | Array of strings |                        |
| `$notIn`           | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" | Array of strings |                        |
| `$re`              | "custom_param1", "custom_param2", "custom_param3", "custom_param4", "custom_param5", "custom_param6", "custom_param7", "custom_param8", "custom_param9", "custom_param10" | Array of strings | Valid regex expression |

### Examples

```json
{
    "conditionType": "customParam",
    "fieldOption": "custom_param1",
    "operator": "$re",
    "value": ["^(?!user).*$","^(?!email).*$"],
}

{
    "conditionType": "customParam",
    "fieldOption": "custom_param5",
    "operator": "$notExists",
}
```