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

# Replace custom list identifiers

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

Replace all existing identifiers in a custom list with new ones.

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

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

### ReplaceIdentifiersResponseContent

- `deleted` (integer, optional) — Number of identifiers deleted
- `added` (integer, optional) — Number of identifiers added
- `total` (integer, optional) — Total number of identifiers after replacement

## Examples

**Request**

```json
[
  {
    "identifier": "socketIps",
    "value": "1.1.1.1"
  },
  {
    "identifier": "socketIpASN",
    "value": "AS158"
  },
  {
    "identifier": "path",
    "value": "test.com"
  },
  {
    "identifier": "custom_param1",
    "value": "custom_param 1"
  },
  {
    "identifier": "custom_param2",
    "value": "custom_param 2"
  }
]
```

**Response**

```json
{
  "result": true,
  "message": "success",
  "content": {
    "deleted": 5,
    "added": 2,
    "total": 2
  }
}
```

**SDK Code**

```python
import requests

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

payload = [
    {
        "identifier": "socketIps",
        "value": "1.1.1.1"
    },
    {
        "identifier": "socketIpASN",
        "value": "AS158"
    },
    {
        "identifier": "path",
        "value": "test.com"
    },
    {
        "identifier": "custom_param1",
        "value": "custom_param 1"
    },
    {
        "identifier": "custom_param2",
        "value": "custom_param 2"
    }
]
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

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/identifiers"

	payload := strings.NewReader("[\n  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"1.1.1.1\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"custom_param 1\"\n  },\n  {\n    \"identifier\": \"custom_param2\",\n    \"value\": \"custom_param 2\"\n  }\n]")

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

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"1.1.1.1\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"custom_param 1\"\n  },\n  {\n    \"identifier\": \"custom_param2\",\n    \"value\": \"custom_param 2\"\n  }\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.put("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\": \"1.1.1.1\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"custom_param 1\"\n  },\n  {\n    \"identifier\": \"custom_param2\",\n    \"value\": \"custom_param 2\"\n  }\n]")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://console.humansecurity.com/api/v1/botDefender/customLists/64f8b12345678901234567ab/identifiers', [
  'body' => '[
  {
    "identifier": "socketIps",
    "value": "1.1.1.1"
  },
  {
    "identifier": "socketIpASN",
    "value": "AS158"
  },
  {
    "identifier": "path",
    "value": "test.com"
  },
  {
    "identifier": "custom_param1",
    "value": "custom_param 1"
  },
  {
    "identifier": "custom_param2",
    "value": "custom_param 2"
  }
]',
  '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/identifiers");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n  {\n    \"identifier\": \"socketIps\",\n    \"value\": \"1.1.1.1\"\n  },\n  {\n    \"identifier\": \"socketIpASN\",\n    \"value\": \"AS158\"\n  },\n  {\n    \"identifier\": \"path\",\n    \"value\": \"test.com\"\n  },\n  {\n    \"identifier\": \"custom_param1\",\n    \"value\": \"custom_param 1\"\n  },\n  {\n    \"identifier\": \"custom_param2\",\n    \"value\": \"custom_param 2\"\n  }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  [
    "identifier": "socketIps",
    "value": "1.1.1.1"
  ],
  [
    "identifier": "socketIpASN",
    "value": "AS158"
  ],
  [
    "identifier": "path",
    "value": "test.com"
  ],
  [
    "identifier": "custom_param1",
    "value": "custom_param 1"
  ],
  [
    "identifier": "custom_param2",
    "value": "custom_param 2"
  ]
] 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 = "PUT"
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()
```