Add IP to Zone whitelist

API endpoint: POST /api/zone/whitelist
POST body
  • zone=ZONE - can be skipped to affect all your zones when adding a single IP / list of IP / IP subnet
  • ip - can be in one of the following formats
    • Add a single IP [string] - ip="1.2.1.2"
    • Add a IP range [string] - ip="1.2.1.2-1.2.1.10"
    • Add a list of IPs [array] - ip=["1.2.1.2","1.2.1.10","1.2.2.12"]
    • Add a IP subnet [string] - ip="10.20.30.40/24"
 
Shell
curl "https://api.brightdata.com/zone/whitelist" -H "Content-Type: application/json" -H "Authorization: Bearer API_TOKEN" -d "{\"zone\":\"ZONE\",\"ip\":\"1.2.1.2\"}"

Node.js

#!/usr/bin/env node
require('request-promise')({
	method: 'POST',
	url: 'https://api.brightdata.com/zone/whitelist',
	json: {'zone': 'ZONE','ip':'1.2.1.2'},
	headers: {'Authorization': 'Bearer API_TOKEN'},
}).then(function(data){ console.log(data); },
	function(err){ console.error(err); });

Java

package example;

import org.apache.http.HttpHost;
import org.apache.http.client.fluent.*;

public class Example {
  public static void main(String[] args) throws Exception {
String body = "{\"zone\":\"ZONE\",\"ip\":\"1.2.1.2\"}"; String res = Executor.newInstance() .addHeader("Authorization", "Bearer API_TOKEN")

.execute(Request.Post("https://api.brightdata.com/zone/whitelist")
.bodyString(body, ContentType.APPLICATION_JSON))

.returnContent().asString();
System.out.println(res) }

}

C#

using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;

public class Program {
  public static async Task Main() {
    var client = new HttpClient();
    var requestMessage = new HttpRequestMessage {
      Method = HttpMethod.Post,
RequestUri = new Uri("https://api.brightdata.com/zone/whitelist"), Headers = { {"Authorization", "Bearer API_TOKEN"} },
Content = new StringContent(JsonConvert.SerializeObject(new {
zone = "ZONE", ip = "1.2.1.2"
}), Encoding.UTF8, "application/json")) }; var response = await client.SendAsync(requestMessage); var responseString = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseString); } }

Python

#!/usr/bin/env python
print('If you get error "ImportError: No module named requests", please install it:\n$ sudo pip install requests');
import requests

data = {'zone': 'ZONE','ip':'1.2.1.2'} headers = {'Authorization': 'Bearer API_TOKEN'} r = requests.post('https://api.brightdata.com/zone/whitelist', data=data, headers=headers) print(r.content)

Was this article helpful?