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

# Update a custom list

PATCH https://console.humansecurity.com/api/v1/botDefender/customLists/{listId}
Content-Type: application/json

Update name, description, or status of an existing custom list by its ID.

Reference: https://docs.humansecurity.com/applications/reference/patch-custom-list

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

- `listId` (string, required) — The unique identifier of the custom list

### Body (application/json)

This endpoint expects an UpdateCustomListRequest.

- `name` (string, optional) — Updated name of the custom list
- `description` (string, optional) — Updated description of the custom list
- `status` (enum, optional) — Updated status of the custom list
  - Allowed values: `active`, `archived`

## Response

### 200

Custom list updated successfully

- `result` (boolean, required) — Indicates if the request was successful
- `message` (string, required) — Response message
- `content` (list of CustomList, optional) — Array containing the updated custom list

## Errors

### 400 Bad Request Error

Invalid request data

- `result` (boolean, required) — Indicates if the request was successful
- `message` (string, required) — Response message
- `content` (string, optional)

### 401 Unauthorized Error

Authentication token is missing or invalid

- `result` (boolean, required) — Indicates if the request was successful
- `message` (string, required) — Response message
- `content` (string, optional)

### 404 Not Found Error

The requested resource was not found

- `result` (boolean, required) — Indicates if the request was successful
- `message` (string, required) — Response message
- `content` (string, optional)

### 500 Internal Server Error

Internal server error

- `result` (boolean, required) — Indicates if the request was successful
- `message` (string, required) — Response message
- `content` (string, optional)

## Types

### CustomList

- `_id` (string, required) — Unique identifier for the custom list
- `account_id` (string, required) — Account ID that owns this custom list
- `name` (string, required) — Name of the custom list
- `status` (enum, required) — Status of the custom list
  - Allowed values: `active`, `archived`
- `created_by` (string, required) — Email of the user who created the list
- `created_at` (string, required) — When the custom list was created
- `updated_at` (string, required) — When the custom list was last updated
- `updated_by` (string, required) — Email of the user who last updated the list
- `size` (integer, required) — Number of identifiers in the list
- `description` (string, optional) — Optional description of the custom list
- `usedBy` (list of CustomListUsedByItems, optional) — List of rules that use the list
- `last_inserted_time` (string, optional) — When the last identifier was added

### CustomListUsedByItems

- `rule_id` (string, optional) — Unique identifier for the rule
- `name` (string, optional) — Name of the rule
- `status` (string, optional) — Status of the rule

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "result": true,
  "message": "success",
  "content": [
    {
      "_id": "64f8b12345678901234567ab",
      "account_id": "642be969c2186cae012347b8",
      "name": "Suspicious Users Blocklist",
      "status": "active",
      "created_by": "admin@humansecurity.com",
      "created_at": "2023-09-01T10:00:00Z",
      "updated_at": "2023-09-01T15:30:00Z",
      "updated_by": "admin@humansecurity.com",
      "size": 150,
      "description": "List of users flagged for suspicious activity",
      "usedBy": [
        {
          "rule_id": "d668491a-f8f8-4b92-a280-c437b4411e0e",
          "name": "Blocklist Rule",
          "status": "active"
        }
      ],
      "last_inserted_time": "2023-09-01T14:00:00Z"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	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/v1/botDefender/customLists/64f8b12345678901234567ab")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.patch("https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```