> 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.

# Delete rule by ID

DELETE https://console.humansecurity.com/api/v2/botDefender/customRules/{ruleId}

Delete a custom rule by the rule's ID.


Reference: https://docs.humansecurity.com/applications/reference/delete-rule-by-id

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://console.humansecurity.com/api` (Version 1 of the API, default)
- `https://console.humansecurity.com/api` (Version 2 of the API)

## Request

### Path parameters

- `ruleId` (string, required) — The ID for the rule. You can get this from the [get custom rules](/applications/reference/get-custom-rules) endpoint or from the Portal's Policy Settings.

## Response

### 200

Success

- `result` (boolean, optional)
- `message` (string, optional)
- `content` (customRule, optional)

## Errors

### 400 Bad Request Error

The request was invalid or did not have the proper authentication.

- `any`

## Types

### customRule

- `name` (string, required)
- `conditions` (CustomRuleConditions, required) — A nested object with **exactly** two levels.
- `actions` (list of enum, required)
  - Allowed values: `allow`, `blockWithChallenge`, `hardBlock`
- `status` (enum, required)
  - Allowed values: `active`, `paused`
- `ruleId` (string, optional)
- `priority` (integer, optional, default: the value corresponding to the lowest priority rule.) — API returns rules between 0 (the highest priority) and the number of rules minus 1 (the lowest priority). This corresponds to the console's rules between 1 (the highest priority) and the number of rules. For example, if there are 10 rules, then in the API, the 0th rule is the highest priority while the 9th rule is the lowest priority. This 0th rule corresponds to the 1st rule in the console. Based on this example, the default value would be 9.
- `description` (string, optional)

### CustomRuleConditions

A nested object with **exactly** two levels.

- `operator` (enum, optional)
  - Allowed values: `$or`, `$and`
- `children` (list of CustomRuleConditionsChildrenItems, optional)

### CustomRuleConditionsChildrenItems

- `operator` (enum, optional)
  - Allowed values: `$or`, `$and`
- `children` (list of CustomRuleConditionsChildrenItemsChildrenItems, optional)

### CustomRuleConditionsChildrenItemsChildrenItems

- `operator` (enum, optional) — The operator to filter with. See [this article](/applications/reference/custom-rule-operators-and-conditions) for details on how to implement.
  - Allowed values: `$eq`, `$contains`, `$startsWith`, `$endsWith`, `$re`, `$notEndsWith`, `$ne`, `$in`, `$notIn`, `$exists`, `$notExists`
- `conditionType` (enum, optional) — The condition to filter by. See [this article](/applications/reference/custom-rule-operators-and-conditions) for details on how to implement.
  - Allowed values: `userAgent`, `domain`, `socketIps`, `socketIpASN`, `path`, `queryParam`, `header`, `httpMethod`, `deviceType`, `country`, `customParam`
- `value` (CustomRuleConditionsChildrenItemsChildrenItemsValue, optional) — The value(s) to match based on the operator. Not required with exists or notExists, but required otherwise. See [this article](/applications/reference/custom-rule-operators-and-conditions) for details on how to implement.
- `fieldOption` (CustomRuleConditionsChildrenItemsChildrenItemsFieldOption, optional) — The name of the field. Only required when using a `queryParam`, `header`, or `customParam` condition. See [this article](/applications/reference/custom-rule-operators-and-conditions) for details on how to implement.

### CustomRuleConditionsChildrenItemsChildrenItemsValue

The value(s) to match based on the operator. Not required with exists or notExists, but required otherwise. See [this article](/applications/reference/custom-rule-operators-and-conditions) for details on how to implement.

### CustomRuleConditionsChildrenItemsChildrenItemsFieldOption

The name of the field. Only required when using a `queryParam`, `header`, or `customParam` condition. See [this article](/applications/reference/custom-rule-operators-and-conditions) for details on how to implement.

## Examples

**Response**

```json
{
  "result": true,
  "message": "success",
  "content": {
    "name": "string",
    "conditions": {
      "operator": "$or",
      "children": [
        {
          "operator": "$or",
          "children": [
            {
              "operator": "$eq",
              "conditionType": "userAgent",
              "value": "string",
              "fieldOption": "string"
            }
          ]
        }
      ]
    },
    "actions": [
      "allow"
    ],
    "status": "active",
    "ruleId": "a747610a-e1d6-4e50-bc60-04c8787ac7b8",
    "priority": 1,
    "description": "string"
  }
}
```

**SDK Code**

```python
import requests

url = "https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8"

headers = {"Authorization": "Bearer <token>"}

response = requests.delete(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8';
const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://console.humansecurity.com/api/v2/botDefender/customRules/a747610a-e1d6-4e50-bc60-04c8787ac7b8")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```