> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/dai-li/dedicated-datacenter-proxies/enterprise/whitelisting-ips/restful/adding-a-whitelisted-ip.md).

# 添加白名单 IP

`POST https://api.oxylabs.io/v1/whitelisted_ips`

| 响应    | 说明                                      |
| ----- | --------------------------------------- |
| `201` | 成功。IP 地址已添加到列表中。响应正文包含新添加的 `地址` 和 `ID`. |
| `422` | 错误。请求正文包含无效的 IP 地址。响应正文包含错误消息           |

#### 代码示例

{% tabs %}
{% tab title="cURL" %}

```shell
curl -X POST -u username:password "https://api.oxylabs.io/v1/whitelisted_ips"
--header "Content-Type: application/json" --data '{"address": "127.0.0.1"}'
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://api.oxylabs.io/v1/whitelisted_ips");
$payload = json_encode( array( "address"=> "127.0.0.1" ) );
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, 'username:password');

$result = curl_exec($curl);
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
requests.post('https://api.oxylabs.io/v1/whitelisted_ips',
              json={"address": "127.0.0.1"},
              auth=('username', 'password'))
```

{% endtab %}
{% endtabs %}

```
{
    "error": {
        "message": "This is not a valid IP address.",
        "code": 422
    }
}
```

#### 示例输出

```
{
    "id": 9767,
    "address": "127.0.0.1"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/products/cn/dai-li/dedicated-datacenter-proxies/enterprise/whitelisting-ips/restful/adding-a-whitelisted-ip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
