> 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 custom list identifiers

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

Add multiple identifiers to a custom list in bulk. If duplicate identifier/value combinations are provided, they will be skipped and counted in the `duplicated` field.


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

## 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 a list of IdentifierAndValue.

- `list of IdentifierAndValue`

## Response

### 200

Identifiers created successfully

- `result` (boolean, required) — Indicates if the request was successful
- `message` (string, required) — Response message
- `content` (CreateIdentifiersResponseContent, 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)

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

### IdentifierAndValue

- `identifier` (enum, required) — Type of identifier
  - Allowed values: `socketIps`, `socketIpASN`, `path`, `custom_param1`, `custom_param2`, `custom_param3`, `custom_param4`, `custom_param5`, `custom_param6`, `custom_param7`, `custom_param8`, `custom_param9`, `custom_param10`
- `value` (string, required) — The identifier value

### CreateIdentifiersResponseContent

- `added` (integer, optional) — Number of identifiers successfully added
- `total` (integer, optional) — Total number of identifiers in the list after addition
- `duplicated` (integer, optional) — Number of duplicate identifiers that were skipped

## Examples

### Successful creation with some duplicates

**Response**

```json
{
  "result": true,
  "message": "success",
  "content": {
    "added": 3,
    "total": 4,
    "duplicated": 1
  }
}
```

**SDK Code**

```python Successful creation with some duplicates
import requests

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

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

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

print(response.json())
```

```javascript Successful creation with some duplicates
const url = 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers';
const options = {method: 'POST', 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 Successful creation with some duplicates
package main

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

func main() {

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

	req, _ := http.NewRequest("POST", 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 Successful creation with some duplicates
require 'uri'
require 'net/http'

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

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

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

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

```java Successful creation with some duplicates
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/64f8b12345678901234567ab/identifiers")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Successful creation with some duplicates
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Successful creation with some duplicates
using RestSharp;

var client = new RestClient("https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Successful creation with some duplicates
import Foundation

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

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

### Mixed identifier types

**Request**

```json
[
  {
    "identifier": "socketIps",
    "value": "192.168.1.100"
  },
  {
    "identifier": "socketIpASN",
    "value": "AS158"
  },
  {
    "identifier": "path",
    "value": "test.example.com"
  },
  {
    "identifier": "custom_param1",
    "value": "test_param_1"
  }
]
```

**Response**

```json
{
  "result": true,
  "message": "success",
  "content": {
    "added": 3,
    "total": 4,
    "duplicated": 1
  }
}
```

**SDK Code**

```python Mixed identifier types
import requests

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

payload = [
    {
        "identifier": "socketIps",
        "value": "192.168.1.100"
    },
    {
        "identifier": "socketIpASN",
        "value": "AS158"
    },
    {
        "identifier": "path",
        "value": "test.example.com"
    },
    {
        "identifier": "custom_param1",
        "value": "test_param_1"
    }
]
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Mixed identifier types
const url = 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '[{"identifier":"socketIps","value":"192.168.1.100"},{"identifier":"socketIpASN","value":"AS158"},{"identifier":"path","value":"test.example.com"},{"identifier":"custom_param1","value":"test_param_1"}]'
};

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

```go Mixed identifier types
package main

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

func main() {

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

	payload := strings.NewReader("[\n  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"192.168.1.100\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.example.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"test_param_1\"\n  }\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 Mixed identifier types
require 'uri'
require 'net/http'

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

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  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"192.168.1.100\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.example.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"test_param_1\"\n  }\n]"

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

```java Mixed identifier types
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/64f8b12345678901234567ab/identifiers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("[\n  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"192.168.1.100\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.example.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"test_param_1\"\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers', [
  'body' => '[
  {
    "identifier": "socketIps",
    "value": "192.168.1.100"
  },
  {
    "identifier": "socketIpASN",
    "value": "AS158"
  },
  {
    "identifier": "path",
    "value": "test.example.com"
  },
  {
    "identifier": "custom_param1",
    "value": "test_param_1"
  }
]',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Mixed identifier types
using RestSharp;

var client = new RestClient("https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"192.168.1.100\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.example.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"test_param_1\"\n  }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Mixed identifier types
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  [
    "identifier": "socketIps",
    "value": "192.168.1.100"
  ],
  [
    "identifier": "socketIpASN",
    "value": "AS158"
  ],
  [
    "identifier": "path",
    "value": "test.example.com"
  ],
  [
    "identifier": "custom_param1",
    "value": "test_param_1"
  ]
] 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/identifiers")! 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()
```