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

# Create a custom list

POST https://console.humansecurity.com/api/v1/botDefender/customLists
Content-Type: application/json

Create a new custom list.

Reference: https://docs.humansecurity.com/applications/reference/create-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

### Body (application/json)

This endpoint expects a CreateCustomListRequest.

- `name` (string, required) — Name of the custom list
- `description` (string, optional) — Optional description of the custom list

## Response

### 200

Custom list created successfully

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

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

### 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
{
  "name": "Suspicious Users Blocklist"
}
```

**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"

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

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

print(response.json())
```

```javascript
const url = 'https://console.humansecurity.com/api/v1/botDefender/customLists';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Suspicious Users Blocklist"}'
};

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"

	payload := strings.NewReader("{\n  \"name\": \"Suspicious Users Blocklist\"\n}")

	req, _ := http.NewRequest("POST", 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")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Suspicious Users Blocklist\"\n}"

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.post("https://console.humansecurity.com/api/v1/botDefender/customLists")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Suspicious Users Blocklist\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://console.humansecurity.com/api/v1/botDefender/customLists', [
  'body' => '{
  "name": "Suspicious Users Blocklist"
}',
  '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");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Suspicious Users Blocklist\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://console.humansecurity.com/api/v1/botDefender/customLists")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```